hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kalnichevski, Oleg" <oleg.kalnichev...@bearingpoint.com>
Subject RE: [PATCH] EntityEnclosingMethod 'modality' fix
Date Mon, 14 Apr 2003 11:40:00 GMT
Thanks for your input

> - PostMethod.setRequestBody(NameValuePair[]) is still using the charset  
> though I am guessing it probably should not.

Oh, man. I totally forgot about it. What it means that the entire PostMethod needs to be rewritten.
I really hate having to do so. I can't help thinking that this patch makes EntityEnclosingMethod
& PostMethod an awful mess for a very little gain. Having to juggle around with a stream,
a string and an array of NameValuePair I fear makes PostMethod error-prone and may lead to
undesirable results under certain circumstances. I am leaning towards just documenting the
assumption regarding 'Content-Type' header and leaving most of the EntityEnclosingMethod &
PostMethod classes as they are. It all gets just way too ugly.

> - getRequestBody() and getRequestBodyAsString() now buffer the input  
> stream.  Though I understand why this is being done I don't really like  
> it.  It takes us back to the problem of not being able to repost a  
> stream request body more than once.  It also makes me wonder what the  
> use case is for getRequestBody*().

There's no use case for getRequestBody() & getRequestBodyAsString() methods. Plain and
simple. They have been created for API completeness and symmetry with setRequestBody(InputStream)
& getRequestBody(String) methods. If implemented as buffering methods these methods should
be invoked by the end user only. There is really no good reason to use these methods in the
very first place, as the content, if the need be, should be re-read from its source, rather
from PostMethod. Nevertheless, since these methods exist, they should be safe to use. Consider
the following situation:
PostMethod httppost = new PostMethod("/whatever");
// Use unbuffered input stream
InputStream instream = getMyInputStream();
// Read the content and return it as a string.
// Since the content has not been buffered, the following method.
// will return an emptry string
// Will post an empty request body

> if we are going to buffer content in getRequestBody*() I think there  
> is a little duplication of work between these methods and  
> bufferContent().

Method bufferContent() is a private method that is called not only from getRequestBody*()
methods but a few others as well. I am missing your point here. Can you shed a bit more light
on it? 



View raw message