You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "Stepan Koltsov (JIRA)" <ji...@apache.org> on 2006/11/30 22:11:21 UTC

[jira] Created: (HTTPCLIENT-610) HttpMethodBase.getResponseBodyAsString(long limit)

HttpMethodBase.getResponseBodyAsString(long limit)
--------------------------------------------------

                 Key: HTTPCLIENT-610
                 URL: http://issues.apache.org/jira/browse/HTTPCLIENT-610
             Project: HttpComponents HttpClient
          Issue Type: Wish
    Affects Versions: 3.1 Alpha 1
            Reporter: Stepan Koltsov
            Priority: Trivial


Currently HttpMethodBase.getResponseBodyAsString() prints warning in log, and suggests using getResponseStream(). However getResponseBodyAsString() is extremely useful (as it is easy to use). So my wish is to have method

getResponseBodyAsString(long limit)

that should throw HttpException if response size exceeds specified limit.

Same things with getResponseBody(long limit) .

Original methods should be deprecated because of danger, explained in javadoc.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: httpcomponents-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpcomponents-dev-help@jakarta.apache.org


[jira] Updated: (HTTPCLIENT-610) HttpMethodBase.getResponseBodyAsString(long limit)

Posted by "Ortwin Glück (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/HTTPCLIENT-610?page=all ]

Ortwin Glück updated HTTPCLIENT-610:
------------------------------------

    Attachment: patch.txt

Proposed patch incl. test cases.

> HttpMethodBase.getResponseBodyAsString(long limit)
> --------------------------------------------------
>
>                 Key: HTTPCLIENT-610
>                 URL: http://issues.apache.org/jira/browse/HTTPCLIENT-610
>             Project: HttpComponents HttpClient
>          Issue Type: Wish
>    Affects Versions: 3.1 Alpha 1
>            Reporter: Stepan Koltsov
>         Assigned To: Ortwin Glück
>            Priority: Trivial
>         Attachments: patch.txt
>
>
> Currently HttpMethodBase.getResponseBodyAsString() prints warning in log, and suggests using getResponseStream(). However getResponseBodyAsString() is extremely useful (as it is easy to use). So my wish is to have method
> getResponseBodyAsString(long limit)
> that should throw HttpException if response size exceeds specified limit.
> Same things with getResponseBody(long limit) .
> Original methods should be deprecated because of danger, explained in javadoc.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

---------------------------------------------------------------------
To unsubscribe, e-mail: httpcomponents-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpcomponents-dev-help@jakarta.apache.org


[jira] Commented: (HTTPCLIENT-610) HttpMethodBase.getResponseBodyAsString(long limit)

Posted by "Stepan Koltsov (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/HTTPCLIENT-610?page=comments#action_12454889 ] 
            
Stepan Koltsov commented on HTTPCLIENT-610:
-------------------------------------------

Thank you for resolving this issue.

However why not add similar

byte[] getResponseBody(long limit)

?

> HttpMethodBase.getResponseBodyAsString(long limit)
> --------------------------------------------------
>
>                 Key: HTTPCLIENT-610
>                 URL: http://issues.apache.org/jira/browse/HTTPCLIENT-610
>             Project: HttpComponents HttpClient
>          Issue Type: Wish
>    Affects Versions: 3.1 Alpha 1
>            Reporter: Stepan Koltsov
>         Assigned To: Ortwin Glück
>            Priority: Trivial
>             Fix For: 3.1 Final
>
>         Attachments: patch-take2.txt
>
>
> Currently HttpMethodBase.getResponseBodyAsString() prints warning in log, and suggests using getResponseStream(). However getResponseBodyAsString() is extremely useful (as it is easy to use). So my wish is to have method
> getResponseBodyAsString(long limit)
> that should throw HttpException if response size exceeds specified limit.
> Same things with getResponseBody(long limit) .
> Original methods should be deprecated because of danger, explained in javadoc.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

---------------------------------------------------------------------
To unsubscribe, e-mail: httpcomponents-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpcomponents-dev-help@jakarta.apache.org


[jira] Commented: (HTTPCLIENT-610) HttpMethodBase.getResponseBodyAsString(long limit)

Posted by "Oleg Kalnichevski (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/HTTPCLIENT-610?page=comments#action_12454891 ] 
            
Oleg Kalnichevski commented on HTTPCLIENT-610:
----------------------------------------------

Odi,

It would also be very nice to have this method ported to HttpCore

http://svn.apache.org/repos/asf/jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/util/EntityUtils.java 

Oleg

> HttpMethodBase.getResponseBodyAsString(long limit)
> --------------------------------------------------
>
>                 Key: HTTPCLIENT-610
>                 URL: http://issues.apache.org/jira/browse/HTTPCLIENT-610
>             Project: HttpComponents HttpClient
>          Issue Type: Wish
>    Affects Versions: 3.1 Alpha 1
>            Reporter: Stepan Koltsov
>         Assigned To: Ortwin Glück
>            Priority: Trivial
>             Fix For: 3.1 Final
>
>         Attachments: patch-take2.txt
>
>
> Currently HttpMethodBase.getResponseBodyAsString() prints warning in log, and suggests using getResponseStream(). However getResponseBodyAsString() is extremely useful (as it is easy to use). So my wish is to have method
> getResponseBodyAsString(long limit)
> that should throw HttpException if response size exceeds specified limit.
> Same things with getResponseBody(long limit) .
> Original methods should be deprecated because of danger, explained in javadoc.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

---------------------------------------------------------------------
To unsubscribe, e-mail: httpcomponents-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpcomponents-dev-help@jakarta.apache.org


[jira] Commented: (HTTPCLIENT-610) HttpMethodBase.getResponseBodyAsString(long limit)

Posted by "Ortwin Glück (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/HTTPCLIENT-610?page=comments#action_12454842 ] 
            
Ortwin Glück commented on HTTPCLIENT-610:
-----------------------------------------

We will not deprecate the old method. If the content length is known, there is no problem calling them.

> HttpMethodBase.getResponseBodyAsString(long limit)
> --------------------------------------------------
>
>                 Key: HTTPCLIENT-610
>                 URL: http://issues.apache.org/jira/browse/HTTPCLIENT-610
>             Project: HttpComponents HttpClient
>          Issue Type: Wish
>    Affects Versions: 3.1 Alpha 1
>            Reporter: Stepan Koltsov
>         Assigned To: Ortwin Glück
>            Priority: Trivial
>
> Currently HttpMethodBase.getResponseBodyAsString() prints warning in log, and suggests using getResponseStream(). However getResponseBodyAsString() is extremely useful (as it is easy to use). So my wish is to have method
> getResponseBodyAsString(long limit)
> that should throw HttpException if response size exceeds specified limit.
> Same things with getResponseBody(long limit) .
> Original methods should be deprecated because of danger, explained in javadoc.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

---------------------------------------------------------------------
To unsubscribe, e-mail: httpcomponents-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpcomponents-dev-help@jakarta.apache.org


[jira] Updated: (HTTPCLIENT-610) HttpMethodBase.getResponseBodyAsString(long limit)

Posted by "Ortwin Glück (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/HTTPCLIENT-610?page=all ]

Ortwin Glück updated HTTPCLIENT-610:
------------------------------------

    Attachment: patch-take2.txt

True. What about the initial size of the ByteArrayOutputStream? By default it's 32 bytes. This means lots of copying and object allocations when the content is large. I guess this makes the method unsuitable for high-performance / low-footprint applications. But those applications are better off using getResponseBodyAsStream() anyway. It's just a convenience method after all.

> HttpMethodBase.getResponseBodyAsString(long limit)
> --------------------------------------------------
>
>                 Key: HTTPCLIENT-610
>                 URL: http://issues.apache.org/jira/browse/HTTPCLIENT-610
>             Project: HttpComponents HttpClient
>          Issue Type: Wish
>    Affects Versions: 3.1 Alpha 1
>            Reporter: Stepan Koltsov
>         Assigned To: Ortwin Glück
>            Priority: Trivial
>         Attachments: patch-take2.txt
>
>
> Currently HttpMethodBase.getResponseBodyAsString() prints warning in log, and suggests using getResponseStream(). However getResponseBodyAsString() is extremely useful (as it is easy to use). So my wish is to have method
> getResponseBodyAsString(long limit)
> that should throw HttpException if response size exceeds specified limit.
> Same things with getResponseBody(long limit) .
> Original methods should be deprecated because of danger, explained in javadoc.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

---------------------------------------------------------------------
To unsubscribe, e-mail: httpcomponents-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpcomponents-dev-help@jakarta.apache.org


[jira] Commented: (HTTPCLIENT-610) HttpMethodBase.getResponseBodyAsString(long limit)

Posted by "Oleg Kalnichevski (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/HTTPCLIENT-610?page=comments#action_12454870 ] 
            
Oleg Kalnichevski commented on HTTPCLIENT-610:
----------------------------------------------

We should apply the same logic as in #getResponseBody method at the very least for the consistency sake:

ByteArrayOutputStream outstream = new ByteArrayOutputStream(
  contentLength > 0 ? (int) contentLength : DEFAULT_INITIAL_BUFFER_SIZE);

Otherwise +1 to commit

Oleg

> HttpMethodBase.getResponseBodyAsString(long limit)
> --------------------------------------------------
>
>                 Key: HTTPCLIENT-610
>                 URL: http://issues.apache.org/jira/browse/HTTPCLIENT-610
>             Project: HttpComponents HttpClient
>          Issue Type: Wish
>    Affects Versions: 3.1 Alpha 1
>            Reporter: Stepan Koltsov
>         Assigned To: Ortwin Glück
>            Priority: Trivial
>         Attachments: patch-take2.txt
>
>
> Currently HttpMethodBase.getResponseBodyAsString() prints warning in log, and suggests using getResponseStream(). However getResponseBodyAsString() is extremely useful (as it is easy to use). So my wish is to have method
> getResponseBodyAsString(long limit)
> that should throw HttpException if response size exceeds specified limit.
> Same things with getResponseBody(long limit) .
> Original methods should be deprecated because of danger, explained in javadoc.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

---------------------------------------------------------------------
To unsubscribe, e-mail: httpcomponents-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpcomponents-dev-help@jakarta.apache.org


[jira] Commented: (HTTPCLIENT-610) HttpMethodBase.getResponseBodyAsString(long limit)

Posted by "Oleg Kalnichevski (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/HTTPCLIENT-610?page=comments#action_12454858 ] 
            
Oleg Kalnichevski commented on HTTPCLIENT-610:
----------------------------------------------

Odi,

In those cases when the content length is not known (because chunk or identity transfer encoding is being used, for insyance) I think it would be more efficient to use  ByteArrayOutputStream instead of pre-allocating the maxLen of bytes. Consider the situation where maxLen is rather largish (say several MB) and chunk coded-content is just a couple of KB.

Oleg

> HttpMethodBase.getResponseBodyAsString(long limit)
> --------------------------------------------------
>
>                 Key: HTTPCLIENT-610
>                 URL: http://issues.apache.org/jira/browse/HTTPCLIENT-610
>             Project: HttpComponents HttpClient
>          Issue Type: Wish
>    Affects Versions: 3.1 Alpha 1
>            Reporter: Stepan Koltsov
>         Assigned To: Ortwin Glück
>            Priority: Trivial
>         Attachments: patch.txt
>
>
> Currently HttpMethodBase.getResponseBodyAsString() prints warning in log, and suggests using getResponseStream(). However getResponseBodyAsString() is extremely useful (as it is easy to use). So my wish is to have method
> getResponseBodyAsString(long limit)
> that should throw HttpException if response size exceeds specified limit.
> Same things with getResponseBody(long limit) .
> Original methods should be deprecated because of danger, explained in javadoc.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

---------------------------------------------------------------------
To unsubscribe, e-mail: httpcomponents-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpcomponents-dev-help@jakarta.apache.org


[jira] Resolved: (HTTPCLIENT-610) HttpMethodBase.getResponseBodyAsString(long limit)

Posted by "Ortwin Glück (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/HTTPCLIENT-610?page=all ]

Ortwin Glück resolved HTTPCLIENT-610.
-------------------------------------

    Fix Version/s: 3.1 Final
       Resolution: Fixed

Patch committed with improvement suggested by Oleg.

> HttpMethodBase.getResponseBodyAsString(long limit)
> --------------------------------------------------
>
>                 Key: HTTPCLIENT-610
>                 URL: http://issues.apache.org/jira/browse/HTTPCLIENT-610
>             Project: HttpComponents HttpClient
>          Issue Type: Wish
>    Affects Versions: 3.1 Alpha 1
>            Reporter: Stepan Koltsov
>         Assigned To: Ortwin Glück
>            Priority: Trivial
>             Fix For: 3.1 Final
>
>         Attachments: patch-take2.txt
>
>
> Currently HttpMethodBase.getResponseBodyAsString() prints warning in log, and suggests using getResponseStream(). However getResponseBodyAsString() is extremely useful (as it is easy to use). So my wish is to have method
> getResponseBodyAsString(long limit)
> that should throw HttpException if response size exceeds specified limit.
> Same things with getResponseBody(long limit) .
> Original methods should be deprecated because of danger, explained in javadoc.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

---------------------------------------------------------------------
To unsubscribe, e-mail: httpcomponents-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpcomponents-dev-help@jakarta.apache.org


[jira] Updated: (HTTPCLIENT-610) HttpMethodBase.getResponseBodyAsString(long limit)

Posted by "Ortwin Glück (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/HTTPCLIENT-610?page=all ]

Ortwin Glück updated HTTPCLIENT-610:
------------------------------------

    Attachment:     (was: patch.txt)

> HttpMethodBase.getResponseBodyAsString(long limit)
> --------------------------------------------------
>
>                 Key: HTTPCLIENT-610
>                 URL: http://issues.apache.org/jira/browse/HTTPCLIENT-610
>             Project: HttpComponents HttpClient
>          Issue Type: Wish
>    Affects Versions: 3.1 Alpha 1
>            Reporter: Stepan Koltsov
>         Assigned To: Ortwin Glück
>            Priority: Trivial
>         Attachments: patch-take2.txt
>
>
> Currently HttpMethodBase.getResponseBodyAsString() prints warning in log, and suggests using getResponseStream(). However getResponseBodyAsString() is extremely useful (as it is easy to use). So my wish is to have method
> getResponseBodyAsString(long limit)
> that should throw HttpException if response size exceeds specified limit.
> Same things with getResponseBody(long limit) .
> Original methods should be deprecated because of danger, explained in javadoc.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

---------------------------------------------------------------------
To unsubscribe, e-mail: httpcomponents-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpcomponents-dev-help@jakarta.apache.org


[jira] Assigned: (HTTPCLIENT-610) HttpMethodBase.getResponseBodyAsString(long limit)

Posted by "Ortwin Glück (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/HTTPCLIENT-610?page=all ]

Ortwin Glück reassigned HTTPCLIENT-610:
---------------------------------------

    Assignee: Ortwin Glück

> HttpMethodBase.getResponseBodyAsString(long limit)
> --------------------------------------------------
>
>                 Key: HTTPCLIENT-610
>                 URL: http://issues.apache.org/jira/browse/HTTPCLIENT-610
>             Project: HttpComponents HttpClient
>          Issue Type: Wish
>    Affects Versions: 3.1 Alpha 1
>            Reporter: Stepan Koltsov
>         Assigned To: Ortwin Glück
>            Priority: Trivial
>
> Currently HttpMethodBase.getResponseBodyAsString() prints warning in log, and suggests using getResponseStream(). However getResponseBodyAsString() is extremely useful (as it is easy to use). So my wish is to have method
> getResponseBodyAsString(long limit)
> that should throw HttpException if response size exceeds specified limit.
> Same things with getResponseBody(long limit) .
> Original methods should be deprecated because of danger, explained in javadoc.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

---------------------------------------------------------------------
To unsubscribe, e-mail: httpcomponents-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpcomponents-dev-help@jakarta.apache.org