JAVA -tomcat- Request header is too large

前端 未结 8 1679
情歌与酒
情歌与酒 2020-12-30 20:18
INFO: Error parsing HTTP request header
 Note: further occurrences of HTTP header parsing errors will be logged at DEBUG level.
java.lang.IllegalArgumentException: R         


        
相关标签:
8条回答
  • 2020-12-30 20:35

    In my case, i was displaying a blob image as a url path <img src="example.com/{extremely-long-base64-encoded-string}"> instead of <img scr="data:;base64,{extremely-long-base64-encoded-string}">

    You notice the difference, that's what caused the error INFO: Error parsing HTTP request header java.lang.IllegalArgumentException: Request header is too large

    0 讨论(0)
  • 2020-12-30 20:37

    The maximum size of the request and response HTTP header, specified in bytes. If not specified, this attribute is set to 4096 (4 KB).

    To avoid getting Error parsing HTTP request header error you can increase the following value by doing this.

    Go to following location: $TOMCAT_HOME/conf/server.xml

    In server.xml change the HTTP/1.1 Connector entry and set the maxHttpHeaderSize to "65536" (64Kb in bytes) as shown below:

    <Connector port="8080" maxHttpHeaderSize="65536" protocol="HTTP/1.1" ... />
    

    Or

    You can use the POST method it can carry upto 2 megabytes according to Tomcat.

    The maximum size in bytes of the POST which will be handled by the container FORM URL parameter parsing. The limit can be disabled by setting this attribute to a value less than or equal to 0. If not specified, this attribute is set to 2097152 (2 megabytes).

    Hope this information would help you..

    0 讨论(0)
  • 2020-12-30 20:38

    here is the question, is there any limit in HTTP headers? The Answer is No. there is no limit but web-servers are limiting their incoming request header size even in POST requests therefore we getting 413 (Request header is too large). This limitation is including request line and header fields.

    http://httpd.apache.org/docs/2.2/mod/core.html#limitrequestfieldsize

    https://tomcat.apache.org/tomcat-5.5-doc/config/http.html

    http://nginx.org/en/docs/http/ngx_http_core_module.html#large_client_header_buffers

    Maximum on http header values?


    In my case, I had SpringBoot 1.5.8 and used HTTP POST, however I had to add:

    server.max-http-header-size=10000000 
    

    in application.properties.

    0 讨论(0)
  • 2020-12-30 20:48

    Solved! I was using HTTP GET instead of HTTP POST. Technically I have seen HttpGet will have issue if the URL length goes beyond 2000 characters. In that case, it's better to use HttpPost or split the URL. Browsers have limits ranging on the 2kb - 8kb

    Tomcat: Request header Too large

    0 讨论(0)
  • 2020-12-30 20:48

    It's not about POST or GET but rather what is the header size limit setup for the Tomcat used by your application.

    You can always control and configure that using app properties as below: server.tomcat.max-http-header-size=1024

    Where 1024 is in Bytes.

    0 讨论(0)
  • 2020-12-30 20:49

    I know it is an old post. However I think it is good to clarify some bits.

    • Using _server.tomcat.max-http-header-size=max_wanted_size_ parameter you will change the server to accept up to max_wanted_size, but even if you set that to 10Mb the browser will cut your request param to the browser limit size. I have tried in chrome and it seems to be around 150-200kb.
    • The java.lang.IllegalArgumentException is happening in the server and it hasn't any to do with the browser. Hence, changing server.tomcat.max-http-header-size should be good enough and it is happening when using GET method but it can also happen when using POST method (In the POST case maxPostSize parameter should be changed).
    0 讨论(0)
提交回复
热议问题