Reproducible code:
require "http/client"
http = HTTP::Client.new("www.google.com", tls: true)
http.read_timeout = 0.01
loop do
sleep 1
http.get "/"
rescue ex : IO::Timeout
puts ex.inspect
end
result:
$ crystal run --release src/bug.cr
#<IO::Timeout:Read timed out>
Unhandled exception: Unsupported HTTP version: ;7[Cs*vs#0UY1D[S+ (Exception)
from /usr/local/Cellar/crystal/0.27.0/src/http/client/response.cr:30:12 in 'exec_internal_single'
from /usr/local/Cellar/crystal/0.27.0/src/http/client.cr:499:5 in '__crystal_main'
Tried to write a spec for it, but then also realized that the read_timeout can't be changed on an active HTTP socket.
I have a fix for this.
Most helpful comment
I have a fix for this.