aboutsummaryrefslogtreecommitdiffstats
path: root/src/cowboy_http_req.erl
diff options
context:
space:
mode:
authorMagnus Klaar <[email protected]>2011-12-27 23:48:23 +0100
committerMagnus Klaar <[email protected]>2011-12-28 18:15:47 +0100
commit612b8f21feed57bea51958487442be1a7c8ae9b1 (patch)
treec17cf4baee8ecda16cd11e217ffe50a29bc277fd /src/cowboy_http_req.erl
parent156c84ff29a13f3d21c1b7ff271bda50797ca0ef (diff)
downloadcowboy-612b8f21feed57bea51958487442be1a7c8ae9b1.tar.gz
cowboy-612b8f21feed57bea51958487442be1a7c8ae9b1.tar.bz2
cowboy-612b8f21feed57bea51958487442be1a7c8ae9b1.zip
Add cowboy_http_req:transport/1 function.
Diffstat (limited to 'src/cowboy_http_req.erl')
-rw-r--r--src/cowboy_http_req.erl14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/cowboy_http_req.erl b/src/cowboy_http_req.erl
index a995871..758346d 100644
--- a/src/cowboy_http_req.erl
+++ b/src/cowboy_http_req.erl
@@ -46,7 +46,7 @@
]). %% Response API.
-export([
- compact/1
+ compact/1, transport/1
]). %% Misc API.
-include("include/http.hrl").
@@ -523,6 +523,18 @@ compact(Req) ->
bindings=undefined, headers=[],
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.
-spec parse_qs(binary(), fun((binary()) -> binary())) ->