mirror of
https://github.com/apache/httpcomponents-client.git
synced 2025-02-27 21:29:12 +00:00
HTTPCLIENT-2105: async clients incorrectly handle redirects of requests with enclosed entity
This commit is contained in:
parent
889159b977
commit
f6da2bac6f
@ -376,6 +376,34 @@ public AsyncServerExchangeHandler decorate(final AsyncServerExchangeHandler exch
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testPostRedirect() throws Exception {
|
||||||
|
final HttpHost target = start(new Decorator<AsyncServerExchangeHandler>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AsyncServerExchangeHandler decorate(final AsyncServerExchangeHandler exchangeHandler) {
|
||||||
|
return new RedirectingAsyncDecorator(
|
||||||
|
exchangeHandler,
|
||||||
|
new OldPathRedirectResolver("/oldlocation", "/echo", HttpStatus.SC_TEMPORARY_REDIRECT));
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
final HttpClientContext context = HttpClientContext.create();
|
||||||
|
|
||||||
|
final SimpleHttpRequest post = SimpleHttpRequests.post(target, "/oldlocation/stuff");
|
||||||
|
post.setBody("stuff", ContentType.TEXT_PLAIN);
|
||||||
|
final Future<SimpleHttpResponse> future = httpclient.execute(post, context, null);
|
||||||
|
final HttpResponse response = future.get();
|
||||||
|
Assert.assertNotNull(response);
|
||||||
|
|
||||||
|
final HttpRequest request = context.getRequest();
|
||||||
|
|
||||||
|
Assert.assertEquals(HttpStatus.SC_OK, response.getCode());
|
||||||
|
Assert.assertEquals("/echo/stuff", request.getRequestUri());
|
||||||
|
Assert.assertEquals("POST", request.getMethod());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPostRedirectSeeOther() throws Exception {
|
public void testPostRedirectSeeOther() throws Exception {
|
||||||
final HttpHost target = start(new Decorator<AsyncServerExchangeHandler>() {
|
final HttpHost target = start(new Decorator<AsyncServerExchangeHandler>() {
|
||||||
|
@ -209,6 +209,9 @@ public void completed() {
|
|||||||
asyncExecCallback.completed();
|
asyncExecCallback.completed();
|
||||||
} else {
|
} else {
|
||||||
final AsyncEntityProducer entityProducer = state.currentEntityProducer;
|
final AsyncEntityProducer entityProducer = state.currentEntityProducer;
|
||||||
|
if (entityProducer != null) {
|
||||||
|
entityProducer.releaseResources();
|
||||||
|
}
|
||||||
if (entityProducer != null && !entityProducer.isRepeatable()) {
|
if (entityProducer != null && !entityProducer.isRepeatable()) {
|
||||||
if (LOG.isDebugEnabled()) {
|
if (LOG.isDebugEnabled()) {
|
||||||
LOG.debug("{}: cannot redirect non-repeatable request", exchangeId);
|
LOG.debug("{}: cannot redirect non-repeatable request", exchangeId);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user