mirror of
https://github.com/ninenines/cowboy.git
synced 2025-07-16 05:00:24 +00:00
Added absoluteURI support
If requests go through a proxy, they will have the original uri in the request, i.e. : GET http://proxy.server.uri/some/query/string HTTP 1.1 ... That was problematic -- cowboy_http_protocol:request didn't know what to to with the result of decode_packet applied to this, which would be something like: ``` erlang {http_request,'GET',{absoluteURI,http,<<"proxy.server.uri">>, undefined,<<"/some/query/string">>},{1,1}} ``` So, I just ignore the host, grab the path and pass into ``` erlang cowboy_http_protocol:request({http_request, Method, {abs_path, Path}, Version}, State) ``` Seems to do the trick without much effort.
This commit is contained in:
parent
062db95653
commit
e7b6e2a402
2 changed files with 6 additions and 1 deletions
|
@ -113,6 +113,10 @@ wait_request(State=#state{socket=Socket, transport=Transport,
|
|||
request({http_request, _Method, _URI, Version}, State)
|
||||
when Version =/= {1, 0}, Version =/= {1, 1} ->
|
||||
error_terminate(505, State);
|
||||
%% We still receive the original Host header.
|
||||
request({http_request, Method, {absoluteURI, _Scheme, _Host, _Port, Path},
|
||||
Version}, State) ->
|
||||
request({http_request, Method, {abs_path, Path}, Version}, State);
|
||||
request({http_request, Method, {abs_path, AbsPath}, Version},
|
||||
State=#state{socket=Socket, transport=Transport,
|
||||
urldecode={URLDecFun, URLDecArg}=URLDec}) ->
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue