Skip to content

Commit

Permalink
fixup! Revise legacy response to work with #470
Browse files Browse the repository at this point in the history
  • Loading branch information
omus committed Sep 29, 2021
1 parent 5eb7e5b commit 584b708
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ function legacy_response(
end
end

body = String(copy(body))
body_str = String(copy(body))

if occursin(r"/xml", mime)
if return_headers
Expand All @@ -118,8 +118,8 @@ function legacy_response(
end

xml_dict_type = response_dict_type{Union{Symbol,String},Any}
body = parse_xml(body)
root = XMLDict.root(body.x)
xml = parse_xml(body_str)
root = XMLDict.root(xml.x)

return (
if return_headers
Expand Down Expand Up @@ -147,8 +147,7 @@ function legacy_response(
)
end

info =
isempty(body) ? nothing : JSON.parse(body; dicttype=response_dict_type)
info = isempty(body) ? nothing : JSON.parse(body_str; dicttype=response_dict_type)
return (return_headers ? (info, response_dict_type(response.headers)) : info)
elseif startswith(mime, "text/")
if return_headers
Expand All @@ -169,7 +168,9 @@ function legacy_response(
)
end

return (return_headers ? (body, response_dict_type(response.headers)) : body)
return (
return_headers ? (body_str, response_dict_type(response.headers)) : body_str
)
else
if return_headers
Base.depwarn(
Expand Down

0 comments on commit 584b708

Please sign in to comment.