urlfetch is not sending long headers

164 views Asked by At

I'm trying to fetch a url using urlfetch on Google App Engine. For some reason, some of the headers are not sent when their value is too long. This only happens on production server (works on my dev machine).

Does this behavior makes sense? Is it documented anywhere? Is there a way to bypass this?

Update: Found this issue from 2011 that says there's an undocumented limit of 481 bytes for the header.

My code:

headers = {
    'LongHeader' : 'LONG_BASE64_VALUE' # 1172 chars
    'ShortHeader' : 'SHORT_VALUE' # 119 chars
}

response = urlfetch.fetch(
    url = url,
    method = urlfetch.GET,
    headers = headers)

# ShortHeader is received by the target server, but LongHeader is not.
1

There are 1 answers

0
Tzach On

It turns out that there are a non documented size limit of about 497 characters for the header size (including the key, color, space after colon and value).

There are open issues on the GAE repository:

https://code.google.com/p/googleappengine/issues/detail?id=10210 https://code.google.com/p/googleappengine/issues/detail?id=5409

And another SO question: Is there a size limit for HTTP response headers on Google App Engine?