1

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.

Community
  • 1
  • 1
Bill
  • 172
  • 8

2 Answers2

1

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.

Zeehad
  • 1,012
  • 1
  • 9
  • 11
  • Yeah, but 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_!), as tx802's comment to the OP hints! – Alex Martelli Feb 09 '16 at 04:27
  • Updated the answer to suggest POST or PUT instead. Thanks @AlexMartelli. – Zeehad Feb 09 '16 at 19:11
  • You're welcome -- and BTW, http://www.faqs.org/rfcs/rfc2616.html recommends a maximum URI length of *255* bytes (see under "3.2.1 General Syntax"), with a status of 414 as the response for too-long URIs... so a FR to extend the limit by *multiple orders of magnitude* above what the RFC recommends __might__ understandably be looked upon with a certain perplexity:-). – Alex Martelli Feb 10 '16 at 01:56
1

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.

Community
  • 1
  • 1
konqi
  • 5,137
  • 3
  • 34
  • 52