hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bartosz Firyn (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (HTTPCLIENT-1089) HTTP Client does not handle 302 redirect in POST request
Date Fri, 13 May 2011 21:38:47 GMT

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

Bartosz Firyn commented on HTTPCLIENT-1089:
-------------------------------------------

Take a look on this code - this is small change, but can save time of many people:

https://github.com/sarxos/httpclient/commit/28124c5d8b489d099926f5496b6fe3acbfbf1f79

Everyone could change default behavior and specify his own set of methods to be redirected.
Example:

		HttpContext context = new BasicHttpContext();
		context.setAttribute(DefaultRedirectStrategy.REDIRECT_METHODS, new String[] {"POST", "GET"});


> HTTP Client does not handle 302 redirect in POST request
> --------------------------------------------------------
>
>                 Key: HTTPCLIENT-1089
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1089
>             Project: HttpComponents HttpClient
>          Issue Type: Bug
>          Components: HttpClient
>    Affects Versions: 4.1.1
>         Environment: *
>            Reporter: Bartosz Firyn
>              Labels: redirect
>   Original Estimate: 1h
>  Remaining Estimate: 1h
>
> POST requests are not being automatically redirected after receiving 302 response.
> This is because there is a statement in the DefaultRedirectStrategy class:
> 82:        case HttpStatus.SC_MOVED_TEMPORARILY:
> 83:            return (method.equalsIgnoreCase(HttpGet.METHOD_NAME)
> 84:                || method.equalsIgnoreCase(HttpHead.METHOD_NAME)) && locationHeader
!= null;
> Which means that only HEAD and GET requests are being redirected. In my opinion all requests
should be redirected, not only these two types.
> This should be:
> 82:        case HttpStatus.SC_MOVED_TEMPORARILY:
> 83:            return locationHeader != null;
> After receiving 302 status for POST request new GET request should be send to Location
URI. Internet browsers works in the same way.
> Best Regards
> Bartosz Firyn

--
This message is automatically generated by JIRA.
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