You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Gustavo Hexsel <gh...@sagebrushcorp.com> on 2004/10/08 00:17:37 UTC
[HttpClient] getting the http connection or setting the params
I'm using HttpClient to read a variable number of pages in sequence. I
have a "time frame" by which the page accesses (method execution and all the
input stream reads) have to be done. I tried calling
method.getParams().setSoTimeout(remainingTime)
but it only sets the timeout once, just before opening the connection. Is
there a way of getting the http connection behind an executing http method?
Or setting the connection parameters?
Thank you!
[]s Gustavo
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org
Re: [HttpClient] getting the http connection or setting the params
Posted by Michael Becke <be...@u.washington.edu>.
On Oct 8, 2004, at 6:41 AM, Tom van den Berge wrote:
> I'm a bit confused with your remarks about method.getParams() and the
> HttpMethod.abort(). They're not in my httpclient api! Are you talking
> about httpclient 2.0.1?
>
Hi Tom,
These are new to HttpClient 3.0.
Mike
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org
Re: [HttpClient] getting the http connection or setting the params
Posted by Tom van den Berge <to...@bibit.com>.
Hi,
HttpClient definitely has timeout settings. You can set a "connection"
timeout, which times out if the ip connection can't be set up quickly
enough, and you can set a "read" timeout, which will effectively abort
your request if the remote server does not respond quickly enough.
Both timeouts can be set in the HttpClient (setConnectionTimeout and
setTimeout, resp.)
If I understand you correctly, you're looking for the setTimeout method.
This will abort your (GET?) method when you execute it through the http
client.
I'm a bit confused with your remarks about method.getParams() and the
HttpMethod.abort(). They're not in my httpclient api! Are you talking
about httpclient 2.0.1?
Cheers,
Tom
> Hi Gustavo,
>
> Not sure what you mean by "setting the connection parameters". All
> timeout params available on the connection are configurable via some
> HttpClient param. Which timeout do you want to set?
>
> Though it is possible to get access to the actual connection it is
> highly discouraged.
>
> It sounds like you may want a method to abort a request after some
> time. HttpClient does not have a built-in "request timeout" param, but
> it can be simulated. You would need a thread separate from the one
> executing the method that keeps track of the method execution time. If
> it went over a timeout value you could call HttpMethod.abort().
>
> Mike
>
> On Oct 7, 2004, at 6:17 PM, Gustavo Hexsel wrote:
>
>> I'm using HttpClient to read a variable number of pages in sequence.
>> I
>> have a "time frame" by which the page accesses (method execution and
>> all the
>> input stream reads) have to be done. I tried calling
>>
>> method.getParams().setSoTimeout(remainingTime)
>>
>> but it only sets the timeout once, just before opening the
>> connection. Is
>> there a way of getting the http connection behind an executing http
>> method?
>> Or setting the connection parameters?
>>
>> Thank you!
>>
>> []s Gustavo
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org
Re: [HttpClient] getting the http connection or setting the params
Posted by Michael Becke <be...@u.washington.edu>.
Hi Gustavo,
Not sure what you mean by "setting the connection parameters". All
timeout params available on the connection are configurable via some
HttpClient param. Which timeout do you want to set?
Though it is possible to get access to the actual connection it is
highly discouraged.
It sounds like you may want a method to abort a request after some
time. HttpClient does not have a built-in "request timeout" param, but
it can be simulated. You would need a thread separate from the one
executing the method that keeps track of the method execution time. If
it went over a timeout value you could call HttpMethod.abort().
Mike
On Oct 7, 2004, at 6:17 PM, Gustavo Hexsel wrote:
> I'm using HttpClient to read a variable number of pages in sequence.
> I
> have a "time frame" by which the page accesses (method execution and
> all the
> input stream reads) have to be done. I tried calling
>
> method.getParams().setSoTimeout(remainingTime)
>
> but it only sets the timeout once, just before opening the
> connection. Is
> there a way of getting the http connection behind an executing http
> method?
> Or setting the connection parameters?
>
> Thank you!
>
> []s Gustavo
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org