Home Ask Login Register

Developers Planet

Your answer is one click away!

Bill February 2016

URL Size in Google App Engine

I am calling a servlet in my app hosted on GAE. The issue I am having is that my request url is greater than 2048 characters and I am getting 400 Bad Request error. While here it is mentioned that we can make a request with 10MB of data. So how can we send a request with 10MB of data? I am currently using free quota. A similar question was asked long ago but it is not answered yet.


Zeehad February 2016

Sending megabytes of data in the request would rather warrant POST or PUT as the request method. This way you can send a request totaling up to 10 megabytes as you've noticed on the referenced article.

The reason you're getting the 400 error is outlined in the urlfetch errors module API documentation; the maximum URL length allowed is 2048 characters.

There is currently an existing feature request for increasing this length; although it's unlikely that this will change in the near future. You can 'star' the issue to get further updates and/or provide your use case in the comments.

konqi February 2016

AppEngine limits aside, it doesn't make much sense to put 10MB of data in an URL.

When you take a look at the HTTP protocol, a GET-request looks like this

GET /path/to/resource?possibleParam=value HTTP/1.1
Host: www.example.com

a POST-request like this

POST /path/to/resource?possibleParam=value HTTP/1.1
Host: www.example.com
Content-Type: */*; charset=utf-8
Content-Length: 4242

here come the actual data with a length of 4242 bytes

So if you allow large amounts of data the in the URI of a GET request that would mean that the server doesn't know how much memory it has to allocate in order to receive the whole uri. So to get better performance it does come quite natural that one would restrict the length of GET requests and force you to use POST request instead where the Content-Length must be made known before actually sending bulks of information.

Let's take a look at the comments from other Stackoverflow users

tx802 said:

POST your data?

Alex Martelli, refering to the maximum allowed URL length, said:

it will never be extended to 10 MB -- that obviously calls for a POST or PUT (where data goes in the body, not the URL!)

That should make sense now, because protocol-wise it doesn't make much sense to push megabytes of data as a URI.

Post Status

Asked in February 2016
Viewed 3,931 times
Voted 4
Answered 2 times


Leave an answer

Quote of the day: live life