code
using Downloads
begin
response_bpdy_io = IOBuffer()
response = request(
"https://httpbin.org/ip",
method="GET",
headers=Dict("accept" => "application/json"),
verbose=true,
output=response_bpdy_io,
)
@show response.status
@show response.message
@show readchomp(response_bpdy_io)
end
output:
response.status = 200
response.message = "HTTP/1.1 200 OK"
readchomp(response_bpdy_io) = ""
The position
of the buffer will be at the end so you are just reading the empty string. You can seekstart
to the beginning before reading:
readchomp(seekstart(response_body_io))
.
1 Like