HTTPCLIENT-1351: Preserve last request URI in the execution context)
Contributed by James Leigh <james at 3roundstones.com> git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1483848 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
45456cf1f0
commit
a679b4f4ec
|
@ -1,8 +1,8 @@
|
||||||
Changes since release 4.3 BETA1
|
Changes since release 4.3 BETA1
|
||||||
-------------------
|
-------------------
|
||||||
|
|
||||||
* [HTTPCLIENT-1351] Preserve last request URI fragment in the execution context.
|
* [HTTPCLIENT-1351] Preserve last request URI in the execution context.
|
||||||
Contributed by Oleg Kalnichevski <olegk at apache.org>
|
Contributed by James Leigh <james at 3roundstones.com>
|
||||||
|
|
||||||
* [HTTPCLIENT-1344] Userinfo credentials in URI should not default to preemptive BASIC
|
* [HTTPCLIENT-1344] Userinfo credentials in URI should not default to preemptive BASIC
|
||||||
authentication.
|
authentication.
|
||||||
|
|
|
@ -27,6 +27,8 @@
|
||||||
|
|
||||||
package org.apache.http.client.protocol;
|
package org.apache.http.client.protocol;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
|
||||||
import org.apache.http.annotation.NotThreadSafe;
|
import org.apache.http.annotation.NotThreadSafe;
|
||||||
import org.apache.http.auth.AuthSchemeProvider;
|
import org.apache.http.auth.AuthSchemeProvider;
|
||||||
import org.apache.http.auth.AuthState;
|
import org.apache.http.auth.AuthState;
|
||||||
|
@ -55,10 +57,10 @@ import org.apache.http.protocol.HttpCoreContext;
|
||||||
public class HttpClientContext extends HttpCoreContext {
|
public class HttpClientContext extends HttpCoreContext {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attribute name of a {@link String} object that represents
|
* Attribute name of a {@link URI} object that represents
|
||||||
* request URI fragment of the actual request.
|
* request URI location (relative or absolute) of the last request target.
|
||||||
*/
|
*/
|
||||||
public static final String URI_FRAGMENT = "http.uri-fragment";
|
public static final String HTTP_LOCATION = "http.location";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attribute name of a {@link org.apache.http.conn.routing.RouteInfo}
|
* Attribute name of a {@link org.apache.http.conn.routing.RouteInfo}
|
||||||
|
@ -158,8 +160,8 @@ public class HttpClientContext extends HttpCoreContext {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUriFragemnt() {
|
public URI getHttpLocation() {
|
||||||
return getAttribute(URI_FRAGMENT, String.class);
|
return getAttribute(HTTP_LOCATION, URI.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public RouteInfo getHttpRoute() {
|
public RouteInfo getHttpRoute() {
|
||||||
|
|
|
@ -79,10 +79,7 @@ public class ProtocolExec implements ClientExecChain {
|
||||||
try {
|
try {
|
||||||
URI uri = request.getURI();
|
URI uri = request.getURI();
|
||||||
if (uri != null) {
|
if (uri != null) {
|
||||||
final String fragment = uri.getFragment();
|
context.setAttribute(HttpClientContext.HTTP_LOCATION, uri);
|
||||||
if (fragment != null) {
|
|
||||||
context.setAttribute(HttpClientContext.URI_FRAGMENT, fragment);
|
|
||||||
}
|
|
||||||
if (route.getProxyHost() != null && !route.isTunnelled()) {
|
if (route.getProxyHost() != null && !route.isTunnelled()) {
|
||||||
// Make sure the request URI is absolute
|
// Make sure the request URI is absolute
|
||||||
if (!uri.isAbsolute()) {
|
if (!uri.isAbsolute()) {
|
||||||
|
|
|
@ -258,6 +258,9 @@ public class TestClientRequestExecution extends IntegrationTestBase {
|
||||||
|
|
||||||
final HttpRequest request = (HttpRequest) context.getAttribute(HttpCoreContext.HTTP_REQUEST);
|
final HttpRequest request = (HttpRequest) context.getAttribute(HttpCoreContext.HTTP_REQUEST);
|
||||||
Assert.assertEquals("/stuff", request.getRequestLine().getUri());
|
Assert.assertEquals("/stuff", request.getRequestLine().getUri());
|
||||||
|
|
||||||
|
final URI location = (URI) context.getAttribute(HttpClientContext.HTTP_LOCATION);
|
||||||
|
Assert.assertEquals(uri, location);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue