Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8306071

Reading response following HTTP redirect upload fails

XMLWordPrintable

    • generic
    • generic

      A DESCRIPTION OF THE PROBLEM :
      When I open a connection and use getOutputStream() with a fixed size first, it will redirect that connection correctly.

      However, when I then use getInputStream() afterwards to read the server's response, I will get an HttpRetryException "cannot retry due to redirection, in streaming mode", generated from sun.net.www.protocol.http.HttpURLConnection.followRedirect0() as streaming() returns true in this case.


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      In pseudo-code:
          connection.setFixedLengthStreamingMode(size);
          connection.setRequestProperty("Content-Type", "application/octet-stream");
          connection.setDoOutput(true);
          try (var output = connection.getOutputStream()) {
              ...
          }
          try (var input = connection.getInputStream()) {
              ...
          }


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      It reuses the existing connection without trying to redirect again (as it already did that successfully).
      ACTUAL -
      A HttpRetryException is thrown.

      CUSTOMER SUBMITTED WORKAROUND :
      Switch to Apache's HTTP implementation.

      FREQUENCY : always


            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: