igrigorik / em-http-request

Asynchronous HTTP Client (EventMachine + Ruby)
1.22k stars 220 forks source link

em-http-request request timeout #290

Closed xiaoshengaimm closed 9 years ago

xiaoshengaimm commented 9 years ago

hi~

how can i control the em-http-request request timeout? ### connect_timeout ### and ### inactivity_timeout ### is about network. but i want control the task timeout.

for example

i want to use em-http-request to download a package. but i want to control the download time less than 5mins, when it greater than 5mins i have other action and stop the task. how can i do it?

and in my program, EM can not be stop.

is there em-http-request support a request_timeout param?

thanks.

igrigorik commented 9 years ago

is there em-http-request support a request_timeout param?

No there isn't. But, this sounds like a use case for regular EM timer: http://www.rubydoc.info/github/eventmachine/eventmachine/EventMachine.add_timer

Set the timer and cancel the request if the timer finishes before the request does.