hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Oleg Kalnichevski (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (HTTPCLIENT-1248) LaxRedirectStrategy converts POST to GET and throws away body
Date Thu, 11 Oct 2012 15:01:06 GMT

    [ https://issues.apache.org/jira/browse/HTTPCLIENT-1248?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13474214#comment-13474214
] 

Oleg Kalnichevski commented on HTTPCLIENT-1248:
-----------------------------------------------

Justus
We are trying to keep HttpClient reasonably well behaved with regards to the HTTP spec compliance
per default and provide extension points to override the default behavior if required. All
you need to do is to subclass lax or default strategy and override one method to get the behavior
you want.

Oleg 
                
> LaxRedirectStrategy converts POST to GET and throws away body
> -------------------------------------------------------------
>
>                 Key: HTTPCLIENT-1248
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1248
>             Project: HttpComponents HttpClient
>          Issue Type: Bug
>    Affects Versions: 4.2.1
>            Reporter: Justus Pendleton
>             Fix For: 4.2.2
>
>
> The LaxRedirectStrategy extends the DefaultRedirectStrategy. The DefaultAsyncRequestDirector
calls _redirectStrategy.isRedirected()_ and LaxRedirectStrategy will return *true* on a POST.
Then the director calls _redirectStrategy.getRedirect()_. The LaxRedirectStrategy doesn't
implement this method so the one in the DefaultRedirectStrategy is called:
> {code}
>         if (method.equalsIgnoreCase(HttpHead.METHOD_NAME)) {
>             return new HttpHead(uri);
>         } else {
>             return new HttpGet(uri);
>         }
> {code}
> This turns the POST into a GET on redirect. IMHO the LaxRedirectStrategy should be
> {code}
>     public HttpUriRequest getRedirect(
>             final HttpRequest request,
>             final HttpResponse response,
>             final HttpContext context) throws ProtocolException {
>         URI uri = getLocationURI(request, response, context);
>         String method = request.getRequestLine().getMethod();
>         if (method.equalsIgnoreCase(HttpHead.METHOD_NAME)) {
>             return new HttpHead(uri);
>         else if (method.equalsIgnoreCase(HttpPost.METHOD_NAME)) {
>             return new HttpPost(uri);
>         } else if (method.equalsIgnoreCase(HttpGet.METHOD_NAME)) {
>             return new HttpGet(uri);
>         } else {
>             throw new IllegalStateException("Redirect called on un-redirectable http
method: " + method);
>     }
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


Mime
View raw message