Crystal: HTTP::Client, request after IO::Timeout raises "Unsupported HTTP version"

Created on 27 Nov 2018  路  2Comments  路  Source: crystal-lang/crystal

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'
bug stdlib

Most helpful comment

I have a fix for this.

All 2 comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

RX14 picture RX14  路  3Comments

lgphp picture lgphp  路  3Comments

asterite picture asterite  路  3Comments

will picture will  路  3Comments

nabeelomer picture nabeelomer  路  3Comments