org.jasig.portlet.emailpreview.dao.exchange
Class AutodiscoverRedirectStrategy
java.lang.Object
org.apache.http.impl.client.DefaultRedirectStrategy
org.apache.http.impl.client.LaxRedirectStrategy
org.jasig.portlet.emailpreview.dao.exchange.AutodiscoverRedirectStrategy
- All Implemented Interfaces:
- org.apache.http.client.RedirectStrategy
@Component
public class AutodiscoverRedirectStrategy
- extends org.apache.http.impl.client.LaxRedirectStrategy
Redirect strategy for http client that allows following redirects (HTTP 301, 302, 307) for POST messages after
validating the redirect location is "safe".
This class does not limit redirect hops; DefaultHttpClient limits redirect hops to 100 (see
ClientPNames.MAX_REDIRECTS ='http.protocol.max-redirects' in
http://hc.apache.org/httpcomponents-client-ga/tutorial/pdf/httpclient-tutorial.pdf.
- Author:
- James Wennmacher, jwennmacher@unicon.net
| Fields inherited from class org.apache.http.impl.client.DefaultRedirectStrategy |
REDIRECT_LOCATIONS |
|
Method Summary |
org.apache.http.client.methods.HttpUriRequest |
getRedirect(org.apache.http.HttpRequest request,
org.apache.http.HttpResponse response,
org.apache.http.protocol.HttpContext context)
Overrides behavior to follow redirects for POST messages, AND to have the redirect be a POST. |
void |
setRequiredUriPatterns(List<String> requiredUriPatterns)
|
void |
setUnsafeUriExclusionPatterns(List<String> unsafeUriExclusionPatterns)
|
| Methods inherited from class org.apache.http.impl.client.LaxRedirectStrategy |
isRedirectable |
| Methods inherited from class org.apache.http.impl.client.DefaultRedirectStrategy |
createLocationURI, getLocationURI, isRedirected |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
AutodiscoverRedirectStrategy
public AutodiscoverRedirectStrategy()
setUnsafeUriExclusionPatterns
public void setUnsafeUriExclusionPatterns(List<String> unsafeUriExclusionPatterns)
setRequiredUriPatterns
public void setRequiredUriPatterns(List<String> requiredUriPatterns)
getRedirect
public org.apache.http.client.methods.HttpUriRequest getRedirect(org.apache.http.HttpRequest request,
org.apache.http.HttpResponse response,
org.apache.http.protocol.HttpContext context)
throws org.apache.http.ProtocolException
- Overrides behavior to follow redirects for POST messages, AND to have the redirect be a POST. Behavior of
DefaultRedirectStrategy is to use a GET for the redirect (though against spec this is the
de-facto standard, see http://www.mail-archive.com/httpclient-users@hc.apache.org/msg06327.html and
http://www.alanflavell.org.uk/www/post-redirect.html).
For our application, we want to follow the redirect for a 302 as long as it is to a safe location and
have the redirect be a POST.
This code is modified from http-components' http-client 4.2.5. Since we only use POST the code for the
other HTTP methods has been removed to simplify this method.
- Specified by:
getRedirect in interface org.apache.http.client.RedirectStrategy- Overrides:
getRedirect in class org.apache.http.impl.client.DefaultRedirectStrategy
- Parameters:
request - Http requestresponse - Http responsecontext - Http context
- Returns:
- Request to issue to the redirected location
- Throws:
org.apache.http.ProtocolException - protocol exception
Copyright © 2013 Jasig. All Rights Reserved.