Skip to content

HTTP.request sidesteps a bit too much ? #463

Closed
@fredrikekre

Description

@fredrikekre

This new method:

request(a...; kw...)::Response = return request(HTTP.stack(;kw...), a...; kw...)
sidesteps a bit too much. I assume it is meant to call the method just above:

HTTP.jl/src/HTTP.jl

Lines 306 to 314 in 7bcb6f5

function request(stack::Type{<:Layer}, method, url, h=Header[], b=nobody;
headers=h, body=b, query=nothing, kw...)::Response
uri = URI(url)
if query !== nothing
uri = merge(uri, query=query)
end
return request(stack, string(method), uri, mkheaders(headers), body; kw...)
end
in order to correctly deal with headers kwargs etc. But that does not happen, because we dispatch to
function request(::Type{RedirectLayer{Next}},
which completely ignores headers (it is included in kwargs...).

Here is an example, where headers is ignored:

julia> using HTTP

julia> uri = HTTP.URI("https://api.github.com");

julia> headers=Dict("User-Agent" => "HTTP.jl");

julia> HTTP.request("GET", uri; headers=headers)
ERROR: HTTP.ExceptionRequest.StatusError(403, "GET", "/", HTTP.Messages.Response:
"""
HTTP/1.0 403 Forbidden
Cache-Control: no-cache
Connection: close
Content-Type: text/html

Request forbidden by administrative rules. Please make sure your request has a User-Agent header (http://developer.github.com/v3/#user-agent-required). Check https://developer.github.com for other possible causes.
""")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions