Error parsing HTTP request header

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



Error parsing HTTP request header



I am trying to send a POST request from browser to my server(local host). My request URL is :


POST


http://localhost:8080/myPath/myServlet?requestData= .......//Json String......;



requestData is a json String (I am using GSON for the purpose.) Everything is working fine until the data in the json string exceeds a particular limit. Say, I am sending array of objects in the json string. If the number of objects in the list exceed 67 then I get following error :


requestData


67


AM org.apache.coyote.http11.AbstractHttp11Processor process
INFO: Error parsing HTTP request header
Note: further occurrences of HTTP header parsing errors will be logged at DEBUG level.



Why is this so? I am totally confused. Why does this happen and what needs to be done to fix this?
I want to understand the reason behind this, for I don't understand that after particular number of objects it suddenly stops working and I get this error in my console.



Thanks.





This seems to be a GET instead POST ...
– user3280180
Oct 22 '14 at 9:29





It seems that you are passing the json string as a GET parameter, not POST.
– damgad
Oct 22 '14 at 9:29


GET


POST





possible duplicate of What is the maximum length of a URL in different browsers?
– Whymarrh
Oct 22 '14 at 9:30





I agree that this might be a duplicate question , Is there any solution ?
– user3686864
Oct 22 '14 at 9:53





You'll get this error message if you are exceeding url length in get requests aswell
– Jonny Leeds
Dec 16 '14 at 15:09




6 Answers
6



It seems that you are using POST incorrectly. Although you are using POST you are sending JSON as a request parameter that is the GET style. When using POST you should send content as a request body. In this case no reasonable size limitation exist.





Can you show how it should be done ?
– user3686864
Oct 22 '14 at 9:30





Please take a look on this tutorial: mkyong.com/java/how-to-send-http-request-getpost-in-java
– AlexR
Oct 22 '14 at 9:31





How can I send it from the browser?
– user3686864
Oct 22 '14 at 9:38





You can write HTML page with form tag, define its method=POST and configure action to your URL, create text area field, then write your JSON there and press button submit.
– AlexR
Oct 22 '14 at 9:41


form


method=POST


action


submit



I had a similar issue, I was sending a POST request (using RESTClient plugin for Firefox) with data in the request body and was receiving the same message.



In my case this happened because I was trying to use HTTPS protocol in a local tomcat instance where HTTPS was not configured.





thanks - that was my problem.
– Simon
Dec 11 '15 at 12:42



In my case problem was caused by security issues, i used csfr for authentication, and all my post forms should have input with _csrf


<input type="hidden" name="$_csrf.parameterName" value="$_csrf.token"/>



I apologize for not answering questions seriously before.



1.Maybe it caused by special characters.You can get details from this url。https://bz.apache.org/bugzilla/show_bug.cgi?id=60594



solve it by:


encodeURIComponent(JSON.stringify(data))



or change your tomcat version to 7.0.67 or lower.
According to developers's opinion, tomcat developers in the following versions set the option to allow |,,.
Get detail http://tomcat.apache.org/tomcat-8.0-doc/config/systemprops.html#Other


|,,



The new environment variable will be included in:
- trunk for 9.0.0.M18 onwards



8.5.x for 8.5.12 onwards



8.0.x for 8.0.42 onwards



7.0.x for 7.0.76 onwards2.



Another reason maybe that Request header is too large.You can solve this by modifying the server.xml.


server.xml


<Connector port="8080" maxHttpHeaderSize="8192" maxThreads="150"
minSpareThreads="25" maxSpareThreads="75" enableLookups="false"
redirectPort="8443" acceptCount="100" connectionTimeout="20000"
disableUploadTimeout="true" />



Hope it works for you!





Try adding example while answering the question to make it more helpful for the person asking.
– Muhammad Omer Aslam
Nov 13 '17 at 6:06





This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker. - From Review
– Bnrdo
Nov 13 '17 at 6:53





Sorry.I've added details of what I know.
– 轩加振
Nov 13 '17 at 8:23



IMHO the problem of parsing the headers can be caused by numerous reasons.


In my case it was due to the fact that the following XML was passed:


<soapenv:Header/>



The empty header element was generated by SoapUI.
After the removal of the <soapenv:Header/> from the XML of the WS then everything was fine.


<soapenv:Header/>



I fixed this by passing an additional header



connection: close, along with the request.



Could you please try and let me know if this works for you.






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

Creating a leaderboard in HTML/JS