Skip to content
This repository has been archived by the owner on May 17, 2019. It is now read-only.

Commit

Permalink
Fix resource header
Browse files Browse the repository at this point in the history
Closes #87.
  • Loading branch information
malmaud committed Dec 2, 2015
1 parent 7e8637d commit 9797063
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
11 changes: 8 additions & 3 deletions src/Requests.jl
Expand Up @@ -197,11 +197,16 @@ function default_request(method,resource,host,data,user_headers=Dict{Union{},Uni
Request(method,resource,headers,data)
end

function default_request(uri::URI,headers,data,method)
resource = "$(uri.scheme)://$(uri.host)$(uri.path)"
function resourcefor(uri::URI)
r = uri.path
if !isempty(uri.query)
resource = "$resource?$(uri.query)"
r = "$r?$(uri.query)"
end
r
end

function default_request(uri::URI,headers,data,method)
resource = resourcefor(uri)
if !isempty(uri.userinfo) && !haskey(headers,"Authorization")
headers["Authorization"] = "Basic $(bytestring(encode(Base64, uri.userinfo)))"
end
Expand Down
5 changes: 4 additions & 1 deletion src/streaming.jl
Expand Up @@ -167,6 +167,7 @@ function open_stream(req::Request, tls_conf=TLS_VERIFY, timeout=Inf,
if scheme(uri) == "http"
if !isnull(http_proxy)
uri = get(http_proxy)
connect_method = :tunnel
end
elseif scheme(uri) == "https"
if !isnull(https_proxy)
Expand All @@ -176,7 +177,9 @@ function open_stream(req::Request, tls_conf=TLS_VERIFY, timeout=Inf,
else
error("Unsupported scheme \"$(scheme(uri))\"")
end

if connect_method == :tunnel
req.resource = "$(req.uri.scheme)://$(req.uri.host)$(resourcefor(req.uri))"
end
ip = Base.getaddrinfo(uri.host)
if scheme(req.uri) == "http"
stream = Base.connect(ip, http_port(uri))
Expand Down

0 comments on commit 9797063

Please sign in to comment.