jira-importer opened a new issue, #992:
URL: https://github.com/apache/httpcomponents-core/issues/992

   **[Nathan 
Reynolds](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=nathanila)**
 opened 
**[HTTPCORE-495](https://issues.apache.org/jira/browse/HTTPCORE-495?redirect=false)**
 and commented
   
   DefaultHttpResponseParser.parseHead() can throw ProtocolException.  Please 
add more diagnostic information in the exception message.  For example, add the 
value of "i", "count" and why reject() returned true.  Please add the contents 
of this.lineBuf and any other information.
   
   My program caught this exception and I am having a hard time to reproduce 
it.  If I had more information in the exception message, then I would be able 
to have a better understanding of why the exception was thrown and how to 
reproduce the issue.
   
   **Exception:**
   org.apache.http.client.ClientProtocolException
   at 
org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:187)
   at 
org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
   ...
   Caused by: org.apache.http.ProtocolException: The server failed to respond 
with a valid HTTP response
   at 
org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:149)
   at 
org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:56)
   at 
org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:259)
   at 
org.apache.http.impl.DefaultBHttpClientConnection.receiveResponseHeader(DefaultBHttpClientConnection.java:163)
   at 
org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:273)
   at 
org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:125)
   at 
org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:272)
   at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:185)
   at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89)
   at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:111)
   at 
org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
   ... 38 more
   
   Here is the method.
   
   > `@Override`
   > protected HttpResponse parseHead(
   > final SessionInputBuffer sessionBuffer) throws IOException, HttpException {
   > //read out the HTTP status string
   > int count = 0;
   > ParserCursor cursor = null;
   > do {
   > // clear the buffer
   > this.lineBuf.clear();
   > final int i = sessionBuffer.readLine(this.lineBuf);
   > if (i == -1 && count == 0) {
   > // The server just dropped connection on us
   > throw new NoHttpResponseException("The target server failed to respond");
   > }
   > cursor = new ParserCursor(0, this.lineBuf.length());
   > if (lineParser.hasProtocolVersion(this.lineBuf, cursor)) {
   > // Got one
   > break;
   > } else if (i == -1 || reject(this.lineBuf, count)) {
   > // Giving up
   > throw new ProtocolException("The server failed to respond with a " +
   > "valid HTTP response");
   > }
   > if (this.log.isDebugEnabled()) {
   > this.log.debug("Garbage in response: " + this.lineBuf.toString());
   > }
   > count++;
   > } while(true);
   > //create the status line from the status string
   > final StatusLine statusline = lineParser.parseStatusLine(this.lineBuf, 
cursor);
   > return this.responseFactory.newHttpResponse(statusline, null);
   > }
   
   
   
   ---
   No further details from 
[HTTPCORE-495](https://issues.apache.org/jira/browse/HTTPCORE-495?redirect=false)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to