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

maxResultLength parameter no effect on reading HttpEntity

    XMLWordPrintableJSON

Details

    • Important

    Description

      maxResultEffect seems to have no effect on the org.apache.hc.core5.http.io.entity.EntityUtils#toByteArray(org.apache.hc.core5.http.HttpEntity, int) method.

      https://github.com/apache/httpcomponents-core/blob/5.1.x/httpcore5/src/main/java/org/apache/hc/core5/http/io/entity/EntityUtils.java#L149

       

      Test (passing) to reproduce the error:

      @Test
      public void testMaxResultLengthNoEffect() throws IOException {
          String random = org.apache.commons.lang3.RandomStringUtils.random(5000, true, true);
          byte[] bytes = org.apache.hc.core5.http.io.entity.EntityUtils.toByteArray(
                  new org.apache.hc.core5.http.io.entity.StringEntity(random)
                  , (int) Math.pow(10, 3));
          String s = new String(bytes);
          Assert.assertEquals(random,s);
      }
      

       

       

      Attachments

        Activity

          People

            Unassigned Unassigned
            amah Andriy
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: