2

I am trying to save an image from Google Images search result but when I send the image's src in the query string parameter it gives the following error:

Request-URI Too Long 
The requested URL's length exceeds the capacity limit for this server.

Apache/2.4.18 (Ubuntu) Server at 127.0.1.1 Port 80

As I am getting this error on my local machine, it is possible for me to test any ideas you all got.

Note: I did set the LimitRequestLine and LimitRequestFieldSize to 100000 in the /etc/apache2/apache2.conf file. But no luck so far.

Any help is appreciated.

Kunal Dethe
  • 1,254
  • 1
  • 18
  • 38

3 Answers3

5

Request parameters cannot have an infinite length. My guess is that you reached the maximum length when sending the image src as a query parameter.

From this answer here it seems like you can set LimitRequestLine and LimitRequestFieldSize to a maximum of 8192 bytes or anything below (so not above) that value.

And in Apache, if you use that as a webservers, you can limit it to something below the default 8190 bytes, but not to something above it without changing the source code & recompiling.

Read also this question which has lots of more information on the maximum length of your url:

This is a popular question, and as the original research is ~9 years old I'll try to keep it up to date: As of Nov 2016, the advice still stands. Even though IE11 may possibly accept longer URLs, the ubiquity of older IE installations plus the search engine limitations mean staying under 2000 chars is the best general policy.

In other words: try to stay under 2000 chars and use POST for sending large amounts of data...

Community
  • 1
  • 1
Wilt
  • 41,477
  • 12
  • 152
  • 203
  • Very useful as I didn't check the line where the `recompiling of the webserver` being involved if the number is greater, like I am requiring. And yes, have thought of `POST` but its not possible in my scenario. As for the `GET`, I am going to ignore images with `src` value more than say `2000`. – Kunal Dethe Nov 29 '16 at 13:05
  • @KunalDethe Happy that my answer was helpful. Why are you limited to using `GET` instead of `POST`? Can you shine some light on that? – Wilt Nov 29 '16 at 13:41
  • I am building a browser extension that should give me an option to save image by providing a download like button over the image. But for the download to happen, it loads the page in iframe and takes the src from the query string. – Kunal Dethe Nov 30 '16 at 13:29
  • So let's say I have a URL that is 17419 long. Is there any chance to get it working without error? I'm using WooCommerce bulk edit huge amount of products at once and would be really helpful to get it working. – Kaspar L. Palgi Aug 17 '18 at 10:15
  • Would it be possible to use POST data for sending that product data to your server instead of your url? In case of edit, I could even imagine another request method like PATCH, or PUT but the concept is the same; send the data inside the request object instead of using the url. – Wilt Aug 17 '18 at 12:17
1

I was also in same problem but solved by adding LimitRequestFieldSize 1000000000 LimitRequestLine 1000000000 lines in httpd.conf file under correct < VirtualHost >

mohit
  • 11
  • 2
0

If you are using CPanel and Cloudflare, this is what i did to solve it:
Home -> Service Configuration -> Apache Configuration -> Include Editor -> Pre VirtualHost Include -> Select an Apache Version

LimitRequestFieldSize 1048576 LimitRequestLine 1048576

Press update then press restart Apache.

I've tried to use above answer and Cloudflare said:
400 Bad Request Request Header Or Cookie Too Large cloudflare-nginx

So I had to lower values.