You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by Hari Iyer <iy...@hotmail.com> on 2025/01/09 19:55:04 UTC

Post redirect behavior in 5.4

Hi,
I migrated httpClient to 5.4 from 4.5 and see a difference in post redirect behavior. In 4.5, a post request does not automatically follow a 302 response but it seems to do so in 5.4. Is this intended? It is not documented in the migration guide. How do I get back the 4.5 behavior?
Thanks,
Hari.

Re: Post redirect behavior in 5.4

Posted by Hari Iyer <iy...@hotmail.com>.
Thank you for the explanation. Since this is the new standard (RFC 9110),  it makes sense for me to just disable redirect for the specific failing request(s) rather than change the client behavior.

________________________________
From: Oleg Kalnichevski <ol...@apache.org>
Sent: Thursday, January 9, 2025 3:20 PM
To: HttpClient User Discussion <ht...@hc.apache.org>
Subject: Re: Post redirect behavior in 5.4

On Thu, 2025-01-09 at 19:55 +0000, Hari Iyer wrote:
> Hi,
> I migrated httpClient to 5.4 from 4.5 and see a difference in post
> redirect behavior. In 4.5, a post request does not automatically
> follow a 302 response but it seems to do so in 5.4. Is this intended?

Yes, it is.

HttpClient 5.4 conforms to the latest HTTP specification (RFC 91xx)
that differs in redirect behavior definition from older revisions of
the specification.

> It is not documented in the migration guide. How do I get back the
> 4.5 behavior?

Replace the standard RedirectExec interceptor with a custom one.

Oleg

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


Re: Post redirect behavior in 5.4

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Thu, 2025-01-09 at 19:55 +0000, Hari Iyer wrote:
> Hi,
> I migrated httpClient to 5.4 from 4.5 and see a difference in post
> redirect behavior. In 4.5, a post request does not automatically
> follow a 302 response but it seems to do so in 5.4. Is this intended?

Yes, it is. 

HttpClient 5.4 conforms to the latest HTTP specification (RFC 91xx)
that differs in redirect behavior definition from older revisions of
the specification.

> It is not documented in the migration guide. How do I get back the
> 4.5 behavior?

Replace the standard RedirectExec interceptor with a custom one.

Oleg

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