add timeout to socket.
add 307 and 308 support
handle EOFError on JRuby 
- caused by calculation of response length
limit redirect times
use read_nonblock so we can set timeout.