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

Make sure we can only reply to an HTTP request inside Handler:handle.

Of course since requests are a record the response state can be explicitly
overriden, but standard use prevents errors by making sure only one reply
is sent.
This commit is contained in:
Loïc Hoguin 2011-03-20 18:03:11 +01:00
parent d69d0adfa7
commit 71b31cee92
3 changed files with 14 additions and 5 deletions

View file

@ -13,9 +13,12 @@
%% OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-record(http_req, {
%% Transport.
socket = undefined :: undefined | socket(),
transport = undefined :: undefined | module(),
connection = keepalive :: keepalive | close,
%% Request.
method = 'GET' :: http_method(),
version = {1, 1} :: http_version(),
peer = undefined :: undefined | {Address::ip_address(), Port::port_number()},
@ -26,6 +29,9 @@
qs_vals = undefined :: undefined | bindings(),
raw_qs = undefined :: undefined | string(),
bindings = undefined :: undefined | bindings(),
headers = [] :: http_headers()
headers = [] :: http_headers(),
%% cookies = undefined :: undefined | http_cookies() %% @todo
%% Response.
resp_state = locked :: locked | waiting | done
}).