Why does the message "Parsing the HTTP request header" error message appear when sending a JSON string?

I am trying to send a POST request from a browser to my server (localhost). URL of my request:

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

requestData is a json string (I use GSON for this purpose.) Everything works fine until the data in the json string exceeds a certain limit. Say I'm sending an array of objects in a json string. If the number of objects in the list exceeds 67 , I get the following error:

  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 completely baffled. Why is this happening and what needs to be done to fix it? I want to understand the reason for this, because I do not understand that after a certain number of objects, it suddenly stops working, and I get this error in my console.

+6
source share
6 answers

It looks like you are using POST incorrectly. Although you use POST, you are sending JSON as a request parameter, which is a GET style. When using POST, you must send the content as the request body. In this case, there is no reasonable size limit.

+4
source

I had a similar problem, I sent a POST request (using the RESTClient plugin for Firefox) with the data in the request body and received the same message.

In my case, this was due to the fact that I was trying to use the HTTPS protocol in a local tomcat instance where HTTPS was not configured.

+4
source

In my case, the problem was caused by security problems, I used csfr for authentication, and all my email forms should have login with _csrf

 <input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}"/> 
+1
source

I apologize for not answering questions seriously before.

1. Perhaps this is caused by special characters. Details can be found at this URL。 https://bz.apache.org/bugzilla/show_bug.cgi?id=60594

solve it :

 encodeURIComponent(JSON.stringify(data)) 

or change tomcat version to 7.0.67 or lower. According to the developers, tomcat developers in the next versions set the permission option |,{,} . Learn more 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 onwards 2.

Another reason may be that the request header is too large. You can solve this problem by changing server.xml .

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

Hope this works for you!

+1
source

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

In my case, this was due to the following XML being sent:

 <soapenv:Header/> 

An empty header element was created by SoapUI. After removing <soapenv:Header/> from XML WS, everything was fine.

0
source

I fixed this by passing an extra header

connection: close with request.

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

0
source

Source: https://habr.com/ru/post/977065/


All Articles