You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "Oleg Kalnichevski (JIRA)" <ji...@apache.org> on 2017/10/20 11:35:01 UTC

[jira] [Moved] (HTTPCORE-495) Add Diagnostic Information to ProtocolException Message

     [ https://issues.apache.org/jira/browse/HTTPCORE-495?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Oleg Kalnichevski moved HTTPCLIENT-1871 to HTTPCORE-495:
--------------------------------------------------------

        Fix Version/s:     (was: 5.0 Alpha3)
                           (was: 4.5.4)
    Affects Version/s:     (was: 4.5.3)
             Workflow: classic default workflow  (was: Default workflow, editable Closed status)
                  Key: HTTPCORE-495  (was: HTTPCLIENT-1871)
              Project: HttpComponents HttpCore  (was: HttpComponents HttpClient)

> Add Diagnostic Information to ProtocolException Message
> -------------------------------------------------------
>
>                 Key: HTTPCORE-495
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-495
>             Project: HttpComponents HttpCore
>          Issue Type: Improvement
>            Reporter: Nathan Reynolds
>            Priority: Minor
>
> 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.
> {quote}
>     @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);
>     }
> {quote}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org