You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "Michael Osipov (Jira)" <ji...@apache.org> on 2019/12/24 17:31:00 UTC

[jira] [Updated] (HTTPCLIENT-2040) Headers are not sent when following redirects

     [ https://issues.apache.org/jira/browse/HTTPCLIENT-2040?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Michael Osipov updated HTTPCLIENT-2040:
---------------------------------------
    Description: 
It appears that headers are not sent when following redirects.

RedirectExec.execute() contains this code:

{code:java} 
                    switch (statusCode) {
                        case HttpStatus.SC_MOVED_PERMANENTLY:
                        case HttpStatus.SC_MOVED_TEMPORARILY:
                        case HttpStatus.SC_SEE_OTHER:
                            if (!Methods.isSafe(request.getMethod())) {
                                final HttpGet httpGet = new HttpGet(redirectUri);
                                httpGet.setHeaders(originalRequest.getHeaders());
                                redirect = httpGet;
                            } else {
                                redirect = null;
                            }
                    }
                    if (redirect == null) {
                        redirect = new BasicClassicHttpRequest(originalRequest.getMethod(), redirectUri);
                        redirect.setEntity(originalRequest.getEntity());
                    }
 {code}

If the method is not 'safe' and converted to a GET, headers get copied from the original request. Otherwise, the original headers are silently dropped.

Desired behavior: Headers should always be copied from the original request. That was the behavior of HttpClient 4.x.

  was:
It appears that headers are not sent when following redirects.

RedirectExec.execute() contains this code:
 
{{                    switch (statusCode) {
                        case HttpStatus.SC_MOVED_PERMANENTLY:
                        case HttpStatus.SC_MOVED_TEMPORARILY:
                        case HttpStatus.SC_SEE_OTHER:
                            if (!Methods.isSafe(request.getMethod())) {
                                final HttpGet httpGet = new HttpGet(redirectUri);
                                httpGet.setHeaders(originalRequest.getHeaders());
                                redirect = httpGet;
                            } else {
                                redirect = null;
                            }
                    }
                    if (redirect == null) {
                        redirect = new BasicClassicHttpRequest(originalRequest.getMethod(), redirectUri);
                        redirect.setEntity(originalRequest.getEntity());
                    }
 }}

If the method is not 'safe' and converted to a GET, headers get copied from the original request. Otherwise, the original headers are silently dropped.

Desired behavior: Headers should always be copied from the original request. That was the behavior of HttpClient 4.x.


> Headers are not sent when following redirects
> ---------------------------------------------
>
>                 Key: HTTPCLIENT-2040
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-2040
>             Project: HttpComponents HttpClient
>          Issue Type: Bug
>          Components: HttpClient (classic)
>    Affects Versions: 5.0 Beta6
>            Reporter: Jeff Schnitzer
>            Priority: Major
>
> It appears that headers are not sent when following redirects.
> RedirectExec.execute() contains this code:
> {code:java} 
>                     switch (statusCode) {
>                         case HttpStatus.SC_MOVED_PERMANENTLY:
>                         case HttpStatus.SC_MOVED_TEMPORARILY:
>                         case HttpStatus.SC_SEE_OTHER:
>                             if (!Methods.isSafe(request.getMethod())) {
>                                 final HttpGet httpGet = new HttpGet(redirectUri);
>                                 httpGet.setHeaders(originalRequest.getHeaders());
>                                 redirect = httpGet;
>                             } else {
>                                 redirect = null;
>                             }
>                     }
>                     if (redirect == null) {
>                         redirect = new BasicClassicHttpRequest(originalRequest.getMethod(), redirectUri);
>                         redirect.setEntity(originalRequest.getEntity());
>                     }
>  {code}
> If the method is not 'safe' and converted to a GET, headers get copied from the original request. Otherwise, the original headers are silently dropped.
> Desired behavior: Headers should always be copied from the original request. That was the behavior of HttpClient 4.x.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

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