Skip to content

Commit

Permalink
Make sure a StatusError is always returned from processreponse. Alter…
Browse files Browse the repository at this point in the history
…native fix to #107 as suggested by @samoconnor
  • Loading branch information
quinnj committed Nov 3, 2017
1 parent 8e3c345 commit 0bb79a7
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/client.jl
Original file line number Diff line number Diff line change
Expand Up @@ -302,12 +302,9 @@ function processresponse!(client, conn, response, host, method, maintask, stream
elseif stream && headerscomplete
@log "processing the rest of response asynchronously"
response.body.task = @async processresponse!(client, conn, response, host, method, maintask, false, tm, canonicalizeheaders, false)
return true, nothing
return true, StatusError(status(response), response)
end
end
# shouldn't ever reach here
dead!(conn)
return false

This comment has been minimized.

Copy link
@samoconnor

samoconnor Nov 3, 2017

Contributor

👍 -- I missed that the top of this was while true

end

function request(client::Client, req::Request, opts::RequestOptions, stream::Bool, history::Vector{Response}, retry::Int, verbose::Bool)
Expand Down Expand Up @@ -337,7 +334,7 @@ function request(client::Client, req::Request, opts::RequestOptions, stream::Boo
if opts.allowredirects::Bool && req.method != HEAD && (300 <= status(response) < 400)
return redirect(response, client, req, opts, stream, history, retry, verbose)
end
if success && ((200 <= status(response) < 300) || !opts.statusraise::Bool)
if (200 <= status(response) < 300) || !opts.statusraise::Bool
return response
else
retry >= opts.retries::Int && throw(err)
Expand Down

0 comments on commit 0bb79a7

Please sign in to comment.