Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/StreamRequest.jl
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ function readbody(http::Stream, res::Response, response_stream, reached_redirect
if reached_redirect_limit || !isredirect(res)
res.body = body_was_streamed
write(response_stream, http)
close(response_stream)
end
end
end
Expand Down
1 change: 1 addition & 0 deletions test/async.jl
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ using Test, HTTP, JSON
try
stream = Base.BufferStream()
response = HTTP.request("GET", url; response_stream=stream, config...)
close(stream)

if response.status != 200
@error "non-200 response" response=response
Expand Down
3 changes: 2 additions & 1 deletion test/client.jl
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,9 @@ end
a = [JSON.parse(l) for l in split(chomp(String(bytes)), "\n")]
totallen = length(bytes) # number of bytes to expect

io = Base.BufferStream()
io = IOBuffer()
r = HTTP.get("$sch://httpbin.org/stream/100"; response_stream=io)
seekstart(io)
@test status(r) == 200

b = [JSON.parse(l) for l in eachline(io)]
Expand Down
2 changes: 1 addition & 1 deletion test/loopback.jl
Original file line number Diff line number Diff line change
Expand Up @@ -349,4 +349,4 @@ end
"Request: POST /delay1 HTTP/1.1",
"Response: HTTP/1.1 200 OK <= (POST /delay1 HTTP/1.1)"]
end
end
end
9 changes: 5 additions & 4 deletions test/messages.jl
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,11 @@ using JSON
@test r.status == 200
r1 = JSON.parse(String(r.body))

io = Base.BufferStream()
io = IOBuffer()
r = request(method, uri, response_stream=io, verbose=1)
seekstart(io)
@test r.status == 200
r2 = JSON.parse(IOBuffer(read(io)))
r2 = JSON.parse(io)
for (k, v) in r1
if k == "headers"
for (k2, v2) in r1[k]
Expand All @@ -136,7 +137,7 @@ using JSON

@testset "Body - JSON Parse" for protocol in protocols, method in http_writes
uri = "$protocol://httpbin.org/$(lowercase(method))"
io = Base.BufferStream()
io = IOBuffer()
r = request(method, uri, response_stream=io, verbose=1)
@test r.status == 200

Expand Down Expand Up @@ -186,4 +187,4 @@ using JSON
# don't display raw binary (non-Unicode) data:
@test repr(Response(200, []; body=String([0xde,0xad,0xc1,0x71,0x1c]))) == "Response:\n\"\"\"\nHTTP/1.1 200 OK\r\n\r\n\n⋮\n5-byte body\n\"\"\""
end
end
end