⚲
Project
General
Profile
Sign in
Register
Home
Projects
Help
Search
:
Ruby master
All Projects
Ruby
»
Ruby master
Overview
Activity
Roadmap
Issues
Repository
Like
Download (832 Bytes)
Bug #13882
ยป http_gzip_hang.rb
wjordan (Will Jordan)
, 05/29/2020 11:41 PM
# Repro https://bugs.ruby-lang.org/issues/13882 using Net::HTTP
# by exiting in the middle of reading gzip-encoded content.
require
'net/http'
HOST
=
'127.0.0.1'
PORT
=
1234
server
=
nil
# Server
t
=
Thread
.
new
do
server
=
TCPServer
.
new
(
HOST
,
PORT
)
c
=
server
.
accept
c
.
print
"HTTP/1.1 200
\r\n
"
c
.
print
"Content-Type: text/plain
\r\n
"
c
.
print
"Content-Encoding: gzip
\r\n
"
s
=
StringIO
.
new
z
=
Zlib
::
GzipWriter
.
new
(
s
)
z
.
write
'Hello World!'
z
.
close
c
.
print
"Content-Length:
#{
s
.
length
}
\r\n\r\n
"
# Write partial gzip content
c
.
write
s
.
string
.
byteslice
(
0
..-
2
)
end
Thread
.
pass
until
server
# Client
Thread
.
new
do
begin
puts
Net
::
HTTP
.
get
(
HOST
,
'/'
,
PORT
)
rescue
Zlib
::
BufError
=>
e
puts
"Caught error:
#{
e
.
inspect
}
"
end
puts
"Sleeping"
sleep
end
at_exit
{
puts
'Exiting'
}
t
.
join
sleep
0.1
(1-1/1)
Loading...