You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by Roger Menday <r....@fz-juelich.de> on 2006/01/31 12:11:21 UTC
inputstream from an unfinished request
Hi,
I am using httpclient productively, but I have a question which I hope
isn't too daft.
I would like to make a POST, and then start reading the response (in a
separate thread) before the entire request has been sent,
getResponseAsStream() appears to be non-null only when the whole request
has been sent.
My wishes are probably somewhat contrary to what HTTP intends to be I
think ...
But ..
Thanks for any help,
Roger
Re: inputstream from an unfinished request
Posted by Roger Menday <r....@fz-juelich.de>.
Hi Roland,
Thanks for your response.
Roland Weber wrote:
>Hi Roger,
>
>
>
>>I would like to make a POST, and then start reading the response (in a
>>separate thread) before the entire request has been sent,
>>
>>
>
>That is not supported by the current API, and probably won't be supported
>by the future one either. The input stream for the response body can not
>be created until the transfer-encoding header of the response has been
>evaluated
>
>
What if the server will always write it's response using chunked
transfer-encoding .. ?
Well, that's probably a bit of a 'what if' ...
Roger
>What you can do is wrap your own input stream around the method and block
>all calls to read() until the thread that is executing the method has the
>response. Then that thread can signal to your wrapper stream that the
>response is available.
>
>hope that helps,
> Roland
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
>
>
>
>
Re: inputstream from an unfinished request
Posted by Roland Weber <ht...@dubioso.net>.
Hi Roger,
> I would like to make a POST, and then start reading the response (in a
> separate thread) before the entire request has been sent,
That is not supported by the current API, and probably won't be supported
by the future one either. The input stream for the response body can not
be created until the transfer-encoding header of the response has been
evaluated.
What you can do is wrap your own input stream around the method and block
all calls to read() until the thread that is executing the method has the
response. Then that thread can signal to your wrapper stream that the
response is available.
hope that helps,
Roland
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
Re: inputstream from an unfinished request
Posted by Michael Becke <mb...@gmail.com>.
Yes, I agree with Roland. This could make sense assuming the server
side complies with this behaviour. As Roland mentioned this is not
possible using HttpClient 3.0, but may be possible in the future.
Mike
On 1/31/06, Roland Weber <ht...@dubioso.net> wrote:
> Hi Roger,
>
> > I want to 'stream' a big payload via HTTP POST to a server, using
> > chunked encoding, and then receive a big payload back in the response
> > (again using chunked). I want the client to start processing this
> > response ASAP, otherwise, I guess, there will be very full buffers
> > somewhere ...
> >
> > Does that make sense ?
>
> Yes, that makes sense. At least if the server starts generating the
> response before it has read the request body completely. But I'm afraid
> that currently HttpClient is not going to check for the response until
> it is finished with sending the request.
> The asynchronous communication for 4.0 would make such an approach
> possible, but we've only just started working on it. I can't see a
> solution for your problem coming anytime soon. I'll remember your
> scenario as a use case to consider, if that is a consolation to you :-)
>
> sorry,
> Roland
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
Re: inputstream from an unfinished request
Posted by Roland Weber <ht...@dubioso.net>.
Hi Roger,
> I want to 'stream' a big payload via HTTP POST to a server, using
> chunked encoding, and then receive a big payload back in the response
> (again using chunked). I want the client to start processing this
> response ASAP, otherwise, I guess, there will be very full buffers
> somewhere ...
>
> Does that make sense ?
Yes, that makes sense. At least if the server starts generating the
response before it has read the request body completely. But I'm afraid
that currently HttpClient is not going to check for the response until
it is finished with sending the request.
The asynchronous communication for 4.0 would make such an approach
possible, but we've only just started working on it. I can't see a
solution for your problem coming anytime soon. I'll remember your
scenario as a use case to consider, if that is a consolation to you :-)
sorry,
Roland
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
Re: inputstream from an unfinished request
Posted by Roger Menday <r....@fz-juelich.de>.
Hi Mike,
Many thanks for your response
>Your guess is correct. The response is not available, at least not
>using HttpClient, until the request has been sent. In general this
>seems like a strange thing to want to do. Is there a particular use
>case you had in mind?
>
>
I want to 'stream' a big payload via HTTP POST to a server, using
chunked encoding, and then receive a big payload back in the response
(again using chunked). I want the client to start processing this
response ASAP, otherwise, I guess, there will be very full buffers
somewhere ...
Does that make sense ?
Roger
>Mike
>
>On 1/31/06, Roger Menday <r....@fz-juelich.de> wrote:
>
>
>>Hi,
>>
>>I am using httpclient productively, but I have a question which I hope
>>isn't too daft.
>>
>>I would like to make a POST, and then start reading the response (in a
>>separate thread) before the entire request has been sent,
>>getResponseAsStream() appears to be non-null only when the whole request
>>has been sent.
>>
>>My wishes are probably somewhat contrary to what HTTP intends to be I
>>think ...
>>But ..
>>
>>Thanks for any help,
>>
>>Roger
>>
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
>>
>>
>>
>>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
>
>
>
>
Re: inputstream from an unfinished request
Posted by Michael Becke <mb...@gmail.com>.
Hi Roger,
Your guess is correct. The response is not available, at least not
using HttpClient, until the request has been sent. In general this
seems like a strange thing to want to do. Is there a particular use
case you had in mind?
Mike
On 1/31/06, Roger Menday <r....@fz-juelich.de> wrote:
>
> Hi,
>
> I am using httpclient productively, but I have a question which I hope
> isn't too daft.
>
> I would like to make a POST, and then start reading the response (in a
> separate thread) before the entire request has been sent,
> getResponseAsStream() appears to be non-null only when the whole request
> has been sent.
>
> My wishes are probably somewhat contrary to what HTTP intends to be I
> think ...
> But ..
>
> Thanks for any help,
>
> Roger
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org