Uploaded image for project: 'HttpComponents HttpClient'
  1. HttpComponents HttpClient
  2. HTTPCLIENT-2040

Headers are not sent when following redirects

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 5.0 Beta6
    • 5.0 Beta7
    • HttpClient (classic)
    • None

    Description

      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.

      Attachments

        Activity

          People

            Unassigned Unassigned
            lhoriman Jeff Schnitzer
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: