"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "httpclient/src/main/java/org/apache/http/impl/client/DefaultRedirectStrategy.java" between
httpcomponents-client-4.5.9-src.tar.gz and httpcomponents-client-4.5.10-src.tar.gz

About: HttpComponents is an Apache project responsible for creating and maintaining a toolset of low level Java components focused on HTTP and associated protocols. Java sources.

DefaultRedirectStrategy.java  (httpcomponents-client-4.5.9-src):DefaultRedirectStrategy.java  (httpcomponents-client-4.5.10-src)
skipping to change at line 32 skipping to change at line 32
* individuals on behalf of the Apache Software Foundation. For more * individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see * information on the Apache Software Foundation, please see
* <http://www.apache.org/>. * <http://www.apache.org/>.
* *
*/ */
package org.apache.http.impl.client; package org.apache.http.impl.client;
import java.net.URI; import java.net.URI;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.util.Arrays;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.apache.http.Header; import org.apache.http.Header;
import org.apache.http.HttpHost; import org.apache.http.HttpHost;
import org.apache.http.HttpRequest; import org.apache.http.HttpRequest;
import org.apache.http.HttpResponse; import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus; import org.apache.http.HttpStatus;
import org.apache.http.ProtocolException; import org.apache.http.ProtocolException;
import org.apache.http.annotation.Contract; import org.apache.http.annotation.Contract;
skipping to change at line 84 skipping to change at line 85
private final Log log = LogFactory.getLog(getClass()); private final Log log = LogFactory.getLog(getClass());
/** /**
* @deprecated (4.3) use {@link org.apache.http.client.protocol.HttpClientCo ntext#REDIRECT_LOCATIONS}. * @deprecated (4.3) use {@link org.apache.http.client.protocol.HttpClientCo ntext#REDIRECT_LOCATIONS}.
*/ */
@Deprecated @Deprecated
public static final String REDIRECT_LOCATIONS = "http.protocol.redirect-loca tions"; public static final String REDIRECT_LOCATIONS = "http.protocol.redirect-loca tions";
public static final DefaultRedirectStrategy INSTANCE = new DefaultRedirectSt rategy(); public static final DefaultRedirectStrategy INSTANCE = new DefaultRedirectSt rategy();
/** private final String[] redirectMethods;
* Redirectable methods.
*/
private static final String[] REDIRECT_METHODS = new String[] {
HttpGet.METHOD_NAME,
HttpHead.METHOD_NAME
};
public DefaultRedirectStrategy() { public DefaultRedirectStrategy() {
this(new String[] {
HttpGet.METHOD_NAME,
HttpHead.METHOD_NAME
});
}
/**
* Constructs a new instance to redirect the given HTTP methods.
*
* @param redirectMethods The methods to redirect.
* @since 4.5.10
*/
public DefaultRedirectStrategy(final String[] redirectMethods) {
super(); super();
final String[] tmp = redirectMethods.clone();
Arrays.sort(tmp);
this.redirectMethods = tmp;
} }
@Override @Override
public boolean isRedirected( public boolean isRedirected(
final HttpRequest request, final HttpRequest request,
final HttpResponse response, final HttpResponse response,
final HttpContext context) throws ProtocolException { final HttpContext context) throws ProtocolException {
Args.notNull(request, "HTTP request"); Args.notNull(request, "HTTP request");
Args.notNull(response, "HTTP response"); Args.notNull(response, "HTTP response");
skipping to change at line 201 skipping to change at line 212
return new URI(location); return new URI(location);
} catch (final URISyntaxException ex) { } catch (final URISyntaxException ex) {
throw new ProtocolException("Invalid redirect URI: " + location, ex) ; throw new ProtocolException("Invalid redirect URI: " + location, ex) ;
} }
} }
/** /**
* @since 4.2 * @since 4.2
*/ */
protected boolean isRedirectable(final String method) { protected boolean isRedirectable(final String method) {
for (final String m: REDIRECT_METHODS) { return Arrays.binarySearch(redirectMethods, method) >= 0;
if (m.equalsIgnoreCase(method)) {
return true;
}
}
return false;
} }
@Override @Override
public HttpUriRequest getRedirect( public HttpUriRequest getRedirect(
final HttpRequest request, final HttpRequest request,
final HttpResponse response, final HttpResponse response,
final HttpContext context) throws ProtocolException { final HttpContext context) throws ProtocolException {
final URI uri = getLocationURI(request, response, context); final URI uri = getLocationURI(request, response, context);
final String method = request.getRequestLine().getMethod(); final String method = request.getRequestLine().getMethod();
if (method.equalsIgnoreCase(HttpHead.METHOD_NAME)) { if (method.equalsIgnoreCase(HttpHead.METHOD_NAME)) {
 End of changes. 5 change blocks. 
13 lines changed or deleted 19 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)