jersey
  1. jersey
  2. JERSEY-2373

ApacheConnector always sets content-length as -1.

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 2.5.1
    • Fix Version/s: backlog
    • Component/s: connectors
    • Labels:
      None

      Description

      It seems the ApacheConnector always returns -1 for the length of the content which is then used to set the content-length header in the request (it's hard coded in the ApacheConnector class).

      Any attempt to override this will result in:

      org.apache.http.ProtocolException: Content-Length header already present
      

      It would be more useful, if the calculation of the content length could be enabled if required, or some strategy could be implemented that defined under which scenarios the content-length was to be calculated.

      See:
      http://stackoverflow.com/questions/18157218/jersey-2-0-content-length-not-set
      https://java.net/projects/jersey/lists/users/archive/2014-01/message/138

      Thanks,

      Will

        Activity

        Show
        Arul Dhesiaseelan added a comment - This is fixed in 2.5 ( JERSEY-2224 ). You could use https://jersey.java.net/apidocs/latest/jersey/org/glassfish/jersey/client/RequestEntityProcessing.html#BUFFERED to stream your content. Here is an example using ApacheConnector: https://github.com/aruld/sof-18157218/blob/master/src/test/java/info/aruld/jersey/EntityStreamingTest.java

          People

          • Assignee:
            Unassigned
            Reporter:
            Will_Ferguson
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated: