nahi / httpclient

'httpclient' gives something like the functionality of libwww-perl (LWP) in Ruby.
https://github.com/nahi/httpclient
703 stars 290 forks source link

Timeout::timeout inherently unsafe, switch to socket nonblocking io #433

Open mohamedhafez opened 3 years ago

mohamedhafez commented 3 years ago

Using Timeout::timeout is inherently unsafe (see https://www.mikeperham.com/2015/05/08/timeout-rubys-most-dangerous-api/ and http://blog.headius.com/2008/02/ruby-threadraise-threadkill-timeoutrb.html), and also inefficient because it spins up a new thread on each invocation.

A better solution would be to switch to all the socket timeout options now available, or to use nonblocking io and IO.select