[
https://issues.apache.org/jira/browse/HTTPCLIENT-1871?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Nathan Reynolds updated HTTPCLIENT-1871:
----------------------------------------
Description:
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);
}
}}
was:
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
> Add Diagnostic Information to ProtocolException Message
> -------------------------------------------------------
>
> Key: HTTPCLIENT-1871
> URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1871
> Project: HttpComponents HttpClient
> Issue Type: Improvement
> Affects Versions: 4.5.3
> 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.
> @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);
> }
> }}
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]