1

Found that the issue is at the load balancer. Basically the api is behind a load balancer proxy. I need to configure the nginx there. I will ask a fresh question for that

I have created an http Server in Golang using stock net/http package. Once in a while I do get some http call with very huge data in the url(It is an API serevr and is expected). For such requests server is responding with HTTP 414 code.

Now I need to know the current length supported by Golang standard http package. From the truncated requests my guess is 10,000 bytes. Is there a way to raise it to something bigger, like 20,000 bytes. I understand that this might affect the server performance, but I need this as a hotfix until we move all the API's to POST.

Post is the way to go, but I need a hotfix. Our clients need huge time to move to POST, I need to support GET for now. I am owner of server, I guess there should be a way to raise the url length limit

Edit:- In the doc:- https://golang.org/src/net/http/server.go, there is MaxHeaderBytes field. The default value is 1MB which is way more than the maximum data I will ever receive(20KB), other header data should not be that big I guess. Then why is it failing with over 8KB of request data?

Mangat Rai Modi
  • 5,397
  • 8
  • 45
  • 75
  • 1
    MaxheaderBytes refers to the max HTTP header length not to the request URL. I think you need to use another HTTP verb, like POST or PUT, the most popular browsers don't support URL greater than 2000 chars, see http://stackoverflow.com/questions/417142/what-is-the-maximum-length-of-a-url-in-different-browsers – Massimo Zerbini Mar 06 '17 at 11:59
  • 5
    "very huge data in the url": That's the problem. Don't do that. POST you should use. – Volker Mar 06 '17 at 12:08
  • @Volker Currently it is a long process to move to post for the clients. – Mangat Rai Modi Mar 06 '17 at 12:16
  • 1
    @MaxZerbini Thanks, the question you shared is about browsers. RFC 7231 doesn't provide any max limit. I expect golang to provide some way to increase this limit, as it is my custom server. – Mangat Rai Modi Mar 06 '17 at 12:19
  • @MangatRaiModi What router are you using ? I don't see Status 414 being set anywhere in the standard library. [Reference](https://github.com/golang/go/search?utf8=✓&q=StatusRequestURITooLong) – John S Perayil Mar 07 '17 at 05:28
  • Ah good point, Just recently I tried without and I was able to parse 32K of url. I am using Gorilla/Mux library - https://github.com/gorilla/mux. btw, standard library also has 414. Search it here - https://golang.org/pkg/net/http/ – Mangat Rai Modi Mar 07 '17 at 05:37
  • @Volker a POST might not be appropriate here -- I found this question because a client needs to do a GET for data for a group of users. Rather than ask them to do 20+ GETs we allow them to put the IDs in the URL, with comma delimiter. A POST wouldn't be valid here since they are "getting" data, not giving us data. – jcollum Apr 07 '20 at 20:29

0 Answers0