You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "THIL Laurent (CAP-GEMINI)" <la...@groupe-mma.fr> on 2015/11/16 16:16:30 UTC
Issue with Http OPTIONS request and htt-client-cache
We have http requests of type OPTIONS that hit the CachingHttpClient that return in exception. I put a stack trace below:
java.lang.NullPointerException
at org.apache.http.impl.client.cache.RequestProtocolCompliance.addContentTypeHeaderIfMissing(RequestProtocolCompliance.java:187)
at org.apache.http.impl.client.cache.RequestProtocolCompliance.verifyOPTIONSRequestWithBodyHasContentType(RequestProtocolCompliance.java:183)
at org.apache.http.impl.client.cache.RequestProtocolCompliance.makeRequestCompliant(RequestProtocolCompliance.java:106)
at org.apache.http.impl.client.cache.CachingHttpClient.execute(CachingHttpClient.java:423)
at org.esigate.cache.CacheAdapter$HttpClientWrapper.execute(CacheAdapter.java:128)
at org.esigate.http.HttpClientHelper.execute(HttpClientHelper.java:238)
at org.esigate.Driver.executeSingleRequest(Driver.java:440)
at org.esigate.Driver.execute(Driver.java:444)
at org.esigate.Driver.proxy(Driver.java:225)
at org.esigate.servlet.AggregatorServlet.service(AggregatorServlet.java:85)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
The problem seem to lie in method addContentTypeHeaderIfMissing:
private void addContentTypeHeaderIfMissing(final HttpEntityEnclosingRequest request) {
if (request.getEntity().getContentType() == null) {
((AbstractHttpEntity) request.getEntity()).setContentType(
ContentType.APPLICATION_OCTET_STREAM.getMimeType());
}
}
The line 'if (request.getEntity(). ' will return null, because there is no entity in a OPTIONS request, from there the null pointer exception.
In the case of a GET request to the CachingHttpClient, the field entity is null as well, but were not running in 'verifyOPTIONSRequestWithBodyHasContentType ...
Is this behavior expected - we are missing something, or truly a bug.
We are currently running httpclient 4.2.5, but I see the same code in the trunk of the project.
Thanks.
Re: Issue with Http OPTIONS request and htt-client-cache
Posted by Oleg Kalnichevski <ol...@apache.org>.
On Mon, 2015-11-16 at 15:16 +0000, THIL Laurent (CAP-GEMINI) wrote:
> We have http requests of type OPTIONS that hit the CachingHttpClient that return in exception. I put a stack trace below:
>
> java.lang.NullPointerException
> at org.apache.http.impl.client.cache.RequestProtocolCompliance.addContentTypeHeaderIfMissing(RequestProtocolCompliance.java:187)
> at org.apache.http.impl.client.cache.RequestProtocolCompliance.verifyOPTIONSRequestWithBodyHasContentType(RequestProtocolCompliance.java:183)
> at org.apache.http.impl.client.cache.RequestProtocolCompliance.makeRequestCompliant(RequestProtocolCompliance.java:106)
> at org.apache.http.impl.client.cache.CachingHttpClient.execute(CachingHttpClient.java:423)
> at org.esigate.cache.CacheAdapter$HttpClientWrapper.execute(CacheAdapter.java:128)
> at org.esigate.http.HttpClientHelper.execute(HttpClientHelper.java:238)
> at org.esigate.Driver.executeSingleRequest(Driver.java:440)
> at org.esigate.Driver.execute(Driver.java:444)
> at org.esigate.Driver.proxy(Driver.java:225)
> at org.esigate.servlet.AggregatorServlet.service(AggregatorServlet.java:85)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
>
>
> The problem seem to lie in method addContentTypeHeaderIfMissing:
>
> private void addContentTypeHeaderIfMissing(final HttpEntityEnclosingRequest request) {
> if (request.getEntity().getContentType() == null) {
> ((AbstractHttpEntity) request.getEntity()).setContentType(
> ContentType.APPLICATION_OCTET_STREAM.getMimeType());
> }
> }
>
> The line 'if (request.getEntity(). ' will return null, because there is no entity in a OPTIONS request, from there the null pointer exception.
> In the case of a GET request to the CachingHttpClient, the field entity is null as well, but were not running in 'verifyOPTIONSRequestWithBodyHasContentType ...
>
> Is this behavior expected - we are missing something, or truly a bug.
>
> We are currently running httpclient 4.2.5, but I see the same code in the trunk of the project.
>
> Thanks.
Please raise a JIRA for this defect and include a test case reproducing
the issue. TestRequestProtocolCompliance might be a good place to look
for existing test cases.
Oleg
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org