You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "Johan Compagner (Jira)" <ji...@apache.org> on 2022/10/04 17:13:00 UTC

[jira] [Commented] (HTTPCLIENT-2051) RedirectExec always changes HTTP method on 301, 302, 303

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

Johan Compagner commented on HTTPCLIENT-2051:
---------------------------------------------

because of this commit i think (not sure how that isSave() previously really worked)

if i do a POST which results in a redirect the code doesn't get into here:

 

[httpcomponents-client/AsyncRedirectExec.java at master · apache/httpcomponents-client (github.com)|https://github.com/apache/httpcomponents-client/blob/master/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/AsyncRedirectExec.java#L153]

 

in the if() part..

 

which means the headers are not copied over, but we need the headers that are set to be copied over (basic authentication but also other specific headers like a specific Jenkins header)

 

So is the only way to not do the auto direct but handles it fully myself?

> RedirectExec always changes HTTP method on 301, 302, 303
> --------------------------------------------------------
>
>                 Key: HTTPCLIENT-2051
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-2051
>             Project: HttpComponents HttpClient
>          Issue Type: Bug
>          Components: HttpClient (classic)
>    Affects Versions: 5.0 Beta7
>            Reporter: Michael Osipov
>            Priority: Major
>             Fix For: 5.0
>
>          Time Spent: 4h
>  Remaining Estimate: 0h
>
> While working on WAGON-570 I noticed that {{RedirectExec}} still sticks to the old scheme to change request method from {{X}} to {{GET}}. 
> I may understand this for 303, but not for the rest. RFC 7231 says:
> bq. Note: For historical reasons, a user agent MAY change the request method from POST to GET for the subsequent request.  If this behavior is undesired, the 307 (Temporary Redirect) status code can be used instead.
> I would assume that the default behavior would *not* change the HTTP method. I'd expect this to be configurable on client or request basis.
> Am I misinterpreting the RFC?



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

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