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

Cannot upload files with HttpClient 4.3.6 using PUT/POST

    XMLWordPrintableJSON

Details

    Description

      Affected component: HttpClient 4.3.6
      Class: org.apache.http.client.entity.EntityBuilder

      When building a new HttpEntity using the EntityBuilder, the method EntityBuilder.setStream() always sets the content length of the stream to 1, which causes http PUT/POST requests to upload only 1 byte, instead of the whole content of the stream.

      Line 319:

      if (this.stream != null) {
                  e = new InputStreamEntity(this.stream, 1, getContentOrDefault(ContentType.DEFAULT_BINARY));
              }
      

      It should be:

      if (this.stream != null) {
                  e = new InputStreamEntity(this.stream, -1, getContentOrDefault(ContentType.DEFAULT_BINARY));
              }
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            SvetlinZarev Svetlin Zarev
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: