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

LaxRedirectStrategy converts POST to GET and throws away body

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 4.2.1
    • 4.2.2
    • None
    • None

    Description

      The LaxRedirectStrategy extends the DefaultRedirectStrategy. The DefaultAsyncRequestDirector calls redirectStrategy.isRedirected() and LaxRedirectStrategy will return true on a POST. Then the director calls redirectStrategy.getRedirect(). The LaxRedirectStrategy doesn't implement this method so the one in the DefaultRedirectStrategy is called:

              if (method.equalsIgnoreCase(HttpHead.METHOD_NAME)) {
                  return new HttpHead(uri);
              } else {
                  return new HttpGet(uri);
              }
      

      This turns the POST into a GET on redirect. IMHO the LaxRedirectStrategy should be

          public HttpUriRequest getRedirect(
                  final HttpRequest request,
                  final HttpResponse response,
                  final HttpContext context) throws ProtocolException {
              URI uri = getLocationURI(request, response, context);
              String method = request.getRequestLine().getMethod();
              if (method.equalsIgnoreCase(HttpHead.METHOD_NAME)) {
                  return new HttpHead(uri);
              else if (method.equalsIgnoreCase(HttpPost.METHOD_NAME)) {
                  return new HttpPost(uri);
              } else if (method.equalsIgnoreCase(HttpGet.METHOD_NAME)) {
                  return new HttpGet(uri);
              } else {
                  throw new IllegalStateException("Redirect called on un-redirectable http method: " + method);
          }
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            jpendleton Justus Pendleton
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: