0
Fork 0
mirror of https://github.com/ninenines/cowboy.git synced 2025-07-15 12:40:25 +00:00

Add cowboy_http_req:transport/1 function.

This commit is contained in:
Magnus Klaar 2011-12-27 23:48:23 +01:00
parent 156c84ff29
commit 612b8f21fe

View file

@ -46,7 +46,7 @@
]). %% Response API. ]). %% Response API.
-export([ -export([
compact/1 compact/1, transport/1
]). %% Misc API. ]). %% Misc API.
-include("include/http.hrl"). -include("include/http.hrl").
@ -523,6 +523,18 @@ compact(Req) ->
bindings=undefined, headers=[], bindings=undefined, headers=[],
p_headers=[], cookies=[]}. p_headers=[], cookies=[]}.
%% @doc Return the transport module and socket associated with a request.
%%
%% This exposes the same socket interface used internally by the HTTP protocol
%% implementation to developers that needs low level access to the socket.
%%
%% It is preferred to use this in conjuction with the stream function support
%% in `set_resp_body/2' if this is used to write a response body directly to
%% the socket. This ensures that the response headers are set correctly.
-spec transport(#http_req{}) -> {ok, module(), inet:socket()}.
transport(#http_req{transport=Transport, socket=Socket}) ->
{ok, Transport, Socket}.
%% Internal. %% Internal.
-spec parse_qs(binary(), fun((binary()) -> binary())) -> -spec parse_qs(binary(), fun((binary()) -> binary())) ->