Browse Source

Rename cowboy_http_req to cowboy_req

Loïc Hoguin 12 years ago
parent
commit
d3dcaf109b

+ 7 - 7
README.md

@@ -85,7 +85,7 @@ init({tcp, http}, Req, Opts) ->
     {ok, Req, undefined_state}.
     {ok, Req, undefined_state}.
 
 
 handle(Req, State) ->
 handle(Req, State) ->
-    {ok, Req2} = cowboy_http_req:reply(200, [], <<"Hello World!">>, Req),
+    {ok, Req2} = cowboy_req:reply(200, [], <<"Hello World!">>, Req),
     {ok, Req2, State}.
     {ok, Req2, State}.
 
 
 terminate(Req, State) ->
 terminate(Req, State) ->
@@ -110,7 +110,7 @@ init({tcp, http}, Req, Opts) ->
 	{loop, Req, undefined_state, ?TIMEOUT, hibernate}.
 	{loop, Req, undefined_state, ?TIMEOUT, hibernate}.
 
 
 info({reply, Body}, Req, State) ->
 info({reply, Body}, Req, State) ->
-	{ok, Req2} = cowboy_http_req:reply(200, [], Body, Req),
+	{ok, Req2} = cowboy_req:reply(200, [], Body, Req),
 	{ok, Req2, State};
 	{ok, Req2, State};
 info(Message, Req, State) ->
 info(Message, Req, State) ->
 	{loop, Req, State, hibernate}.
 	{loop, Req, State, hibernate}.
@@ -149,13 +149,13 @@ example, host rule `['...', <<"ninenines">>, <<"eu">>]` can match both
 "cowboy.bugs.ninenines.eu" and "ninenines.eu" and path rule
 "cowboy.bugs.ninenines.eu" and "ninenines.eu" and path rule
 `[<<"projects">>, '...']` can match both "/projects" and
 `[<<"projects">>, '...']` can match both "/projects" and
 "/projects/cowboy/issues/42". The host leading segments and the path trailing
 "/projects/cowboy/issues/42". The host leading segments and the path trailing
-segments can later be retrieved through `cowboy_http_req:host_info/1` and
-`cowboy_http_req:path_info/1`.
+segments can later be retrieved through `cowboy_req:host_info/1` and
+`cowboy_req:path_info/1`.
 
 
 Any other atom used as a token will bind the value to this atom when
 Any other atom used as a token will bind the value to this atom when
 matching. To follow on our hostnames example, `[<<"ninenines">>, ext]`
 matching. To follow on our hostnames example, `[<<"ninenines">>, ext]`
 would bind the values `<<"eu">>` and `<<"fr">>` to the ext atom, that you
 would bind the values `<<"eu">>` and `<<"fr">>` to the ext atom, that you
-can later retrieve in your handler by calling `cowboy_http_req:binding/{2,3}`.
+can later retrieve in your handler by calling `cowboy_req:binding/{2,3}`.
 
 
 You can also accept any match spec by using the atom `'_'` directly instead of
 You can also accept any match spec by using the atom `'_'` directly instead of
 a list of tokens. Our hello world example above uses this to forward all
 a list of tokens. Our hello world example above uses this to forward all
@@ -168,7 +168,7 @@ Requests handling
 
 
 Requests are passed around in the Request variable. Although they are
 Requests are passed around in the Request variable. Although they are
 defined as a record, it is recommended to access them only through the
 defined as a record, it is recommended to access them only through the
-cowboy_http_req module API.
+cowboy_req module API.
 
 
 You can retrieve the HTTP method, HTTP version, peer address and port,
 You can retrieve the HTTP method, HTTP version, peer address and port,
 host tokens, raw host, used port, path tokens, raw path, query string
 host tokens, raw host, used port, path tokens, raw path, query string
@@ -177,7 +177,7 @@ request. You can also read the request body, if any, optionally parsing
 it as a query string. Finally, the request allows you to send a response
 it as a query string. Finally, the request allows you to send a response
 to the client.
 to the client.
 
 
-See the cowboy_http_req module for more information.
+See the cowboy_req module for more information.
 
 
 Websockets
 Websockets
 ----------
 ----------

+ 4 - 4
examples/chunked_hello_world/src/toppage_handler.erl

@@ -11,12 +11,12 @@ init(_Transport, Req, []) ->
 	{ok, Req, undefined}.
 	{ok, Req, undefined}.
 
 
 handle(Req, State) ->
 handle(Req, State) ->
-	{ok, Req2} = cowboy_http_req:chunked_reply(200, Req),
-	ok = cowboy_http_req:chunk("Hello\r\n", Req2),
+	{ok, Req2} = cowboy_req:chunked_reply(200, Req),
+	ok = cowboy_req:chunk("Hello\r\n", Req2),
 	ok = timer:sleep(1000),
 	ok = timer:sleep(1000),
-	ok = cowboy_http_req:chunk("World\r\n", Req2),
+	ok = cowboy_req:chunk("World\r\n", Req2),
 	ok = timer:sleep(1000),
 	ok = timer:sleep(1000),
-	ok = cowboy_http_req:chunk("Chunked!\r\n", Req2),
+	ok = cowboy_req:chunk("Chunked!\r\n", Req2),
 	{ok, Req2, State}.
 	{ok, Req2, State}.
 
 
 terminate(_Req, _State) ->
 terminate(_Req, _State) ->

+ 5 - 5
examples/echo_get/src/toppage_handler.erl

@@ -11,19 +11,19 @@ init(_Transport, Req, []) ->
 	{ok, Req, undefined}.
 	{ok, Req, undefined}.
 
 
 handle(Req, State) ->
 handle(Req, State) ->
-	{Method, Req2} = cowboy_http_req:method(Req),
-	{Echo, Req3} = cowboy_http_req:qs_val(<<"echo">>, Req2),
+	{Method, Req2} = cowboy_req:method(Req),
+	{Echo, Req3} = cowboy_req:qs_val(<<"echo">>, Req2),
 	{ok, Req4} = echo(Method, Echo, Req3),
 	{ok, Req4} = echo(Method, Echo, Req3),
 	{ok, Req4, State}.
 	{ok, Req4, State}.
 
 
 echo('GET', undefined, Req) ->
 echo('GET', undefined, Req) ->
-	cowboy_http_req:reply(400, [], <<"Missing echo parameter.">>, Req);
+	cowboy_req:reply(400, [], <<"Missing echo parameter.">>, Req);
 echo('GET', Echo, Req) ->
 echo('GET', Echo, Req) ->
-	cowboy_http_req:reply(200,
+	cowboy_req:reply(200,
 		[{<<"Content-Encoding">>, <<"utf-8">>}], Echo, Req);
 		[{<<"Content-Encoding">>, <<"utf-8">>}], Echo, Req);
 echo(_, _, Req) ->
 echo(_, _, Req) ->
 	%% Method not allowed.
 	%% Method not allowed.
-	cowboy_http_req:reply(405, Req).
+	cowboy_req:reply(405, Req).
 
 
 terminate(_Req, _State) ->
 terminate(_Req, _State) ->
 	ok.
 	ok.

+ 7 - 7
examples/echo_post/src/toppage_handler.erl

@@ -11,25 +11,25 @@ init(_Transport, Req, []) ->
 	{ok, Req, undefined}.
 	{ok, Req, undefined}.
 
 
 handle(Req, State) ->
 handle(Req, State) ->
-	{Method, Req2} = cowboy_http_req:method(Req),
-	{HasBody, Req3} = cowboy_http_req:has_body(Req2),
+	{Method, Req2} = cowboy_req:method(Req),
+	{HasBody, Req3} = cowboy_req:has_body(Req2),
 	{ok, Req4} = maybe_echo(Method, HasBody, Req3),
 	{ok, Req4} = maybe_echo(Method, HasBody, Req3),
 	{ok, Req4, State}.
 	{ok, Req4, State}.
 
 
 maybe_echo('POST', true, Req) ->
 maybe_echo('POST', true, Req) ->
-	{PostVals, Req2} = cowboy_http_req:body_qs(Req),
+	{PostVals, Req2} = cowboy_req:body_qs(Req),
 	Echo = proplists:get_value(<<"echo">>, PostVals),
 	Echo = proplists:get_value(<<"echo">>, PostVals),
 	echo(Echo, Req2);
 	echo(Echo, Req2);
 maybe_echo('POST', false, Req) ->
 maybe_echo('POST', false, Req) ->
-	cowboy_http_req:reply(400, [], <<"Missing body.">>, Req);
+	cowboy_req:reply(400, [], <<"Missing body.">>, Req);
 maybe_echo(_, _, Req) ->
 maybe_echo(_, _, Req) ->
 	%% Method not allowed.
 	%% Method not allowed.
-	cowboy_http_req:reply(405, Req).
+	cowboy_req:reply(405, Req).
 
 
 echo(undefined, Req) ->
 echo(undefined, Req) ->
-	cowboy_http_req:reply(400, [], <<"Missing echo parameter.">>, Req);
+	cowboy_req:reply(400, [], <<"Missing echo parameter.">>, Req);
 echo(Echo, Req) ->
 echo(Echo, Req) ->
-	cowboy_http_req:reply(200,
+	cowboy_req:reply(200,
 		[{<<"Content-Encoding">>, <<"utf-8">>}], Echo, Req).
 		[{<<"Content-Encoding">>, <<"utf-8">>}], Echo, Req).
 
 
 terminate(_Req, _State) ->
 terminate(_Req, _State) ->

+ 1 - 1
examples/hello_world/src/toppage_handler.erl

@@ -11,7 +11,7 @@ init(_Transport, Req, []) ->
 	{ok, Req, undefined}.
 	{ok, Req, undefined}.
 
 
 handle(Req, State) ->
 handle(Req, State) ->
-	{ok, Req2} = cowboy_http_req:reply(200, [], <<"Hello world!">>, Req),
+	{ok, Req2} = cowboy_req:reply(200, [], <<"Hello world!">>, Req),
 	{ok, Req2, State}.
 	{ok, Req2, State}.
 
 
 terminate(_Req, _State) ->
 terminate(_Req, _State) ->

+ 27 - 27
src/cowboy_http_rest.erl

@@ -75,7 +75,7 @@ upgrade(_ListenerPid, Handler, Opts, Req) ->
 			"   for the reason ~p:~p~n** Options were ~p~n"
 			"   for the reason ~p:~p~n** Options were ~p~n"
 			"** Request was ~p~n** Stacktrace: ~p~n~n",
 			"** Request was ~p~n** Stacktrace: ~p~n~n",
 			[Handler, Class, Reason, Opts, PLReq, erlang:get_stacktrace()]),
 			[Handler, Class, Reason, Opts, PLReq, erlang:get_stacktrace()]),
-		{ok, _Req2} = cowboy_http_req:reply(500, Req),
+		{ok, _Req2} = cowboy_req:reply(500, Req),
 		close
 		close
 	end.
 	end.
 
 
@@ -122,7 +122,7 @@ allowed_methods(Req=#http_req{method=Method}, State) ->
 	end.
 	end.
 
 
 method_not_allowed(Req, State, Methods) ->
 method_not_allowed(Req, State, Methods) ->
-	{ok, Req2} = cowboy_http_req:set_resp_header(
+	{ok, Req2} = cowboy_req:set_resp_header(
 		<<"Allow">>, method_not_allowed_build(Methods, []), Req),
 		<<"Allow">>, method_not_allowed_build(Methods, []), Req),
 	respond(Req2, State, 405).
 	respond(Req2, State, 405).
 
 
@@ -149,7 +149,7 @@ is_authorized(Req, State) ->
 		{true, Req2, HandlerState} ->
 		{true, Req2, HandlerState} ->
 			forbidden(Req2, State#state{handler_state=HandlerState});
 			forbidden(Req2, State#state{handler_state=HandlerState});
 		{{false, AuthHead}, Req2, HandlerState} ->
 		{{false, AuthHead}, Req2, HandlerState} ->
-			{ok, Req3} = cowboy_http_req:set_resp_header(
+			{ok, Req3} = cowboy_req:set_resp_header(
 				<<"Www-Authenticate">>, AuthHead, Req2),
 				<<"Www-Authenticate">>, AuthHead, Req2),
 			respond(Req3, State#state{handler_state=HandlerState}, 401)
 			respond(Req3, State#state{handler_state=HandlerState}, 401)
 	end.
 	end.
@@ -207,7 +207,7 @@ content_types_provided(Req=#http_req{meta=Meta}, State) ->
 		    CTP2 = [normalize_content_types(P) || P <- CTP],
 		    CTP2 = [normalize_content_types(P) || P <- CTP],
 			State2 = State#state{
 			State2 = State#state{
 				handler_state=HandlerState, content_types_p=CTP2},
 				handler_state=HandlerState, content_types_p=CTP2},
-			{Accept, Req3} = cowboy_http_req:parse_header('Accept', Req2),
+			{Accept, Req3} = cowboy_req:parse_header('Accept', Req2),
 			case Accept of
 			case Accept of
 				undefined ->
 				undefined ->
 					{PMT, _Fun} = HeadCTP = hd(CTP2),
 					{PMT, _Fun} = HeadCTP = hd(CTP2),
@@ -302,7 +302,7 @@ languages_provided(Req, State) ->
 		{LP, Req2, HandlerState} ->
 		{LP, Req2, HandlerState} ->
 			State2 = State#state{handler_state=HandlerState, languages_p=LP},
 			State2 = State#state{handler_state=HandlerState, languages_p=LP},
 			{AcceptLanguage, Req3} =
 			{AcceptLanguage, Req3} =
-				cowboy_http_req:parse_header('Accept-Language', Req2),
+				cowboy_req:parse_header('Accept-Language', Req2),
 			case AcceptLanguage of
 			case AcceptLanguage of
 				undefined ->
 				undefined ->
 					set_language(Req3, State2#state{language_a=hd(LP)});
 					set_language(Req3, State2#state{language_a=hd(LP)});
@@ -348,7 +348,7 @@ match_language(Req, State, Accept, [Provided|Tail],
 	end.
 	end.
 
 
 set_language(Req=#http_req{meta=Meta}, State=#state{language_a=Language}) ->
 set_language(Req=#http_req{meta=Meta}, State=#state{language_a=Language}) ->
-	{ok, Req2} = cowboy_http_req:set_resp_header(
+	{ok, Req2} = cowboy_req:set_resp_header(
 		<<"Content-Language">>, Language, Req),
 		<<"Content-Language">>, Language, Req),
 	charsets_provided(Req2#http_req{meta=[{language, Language}|Meta]}, State).
 	charsets_provided(Req2#http_req{meta=[{language, Language}|Meta]}, State).
 
 
@@ -365,7 +365,7 @@ charsets_provided(Req, State) ->
 		{CP, Req2, HandlerState} ->
 		{CP, Req2, HandlerState} ->
 			State2 = State#state{handler_state=HandlerState, charsets_p=CP},
 			State2 = State#state{handler_state=HandlerState, charsets_p=CP},
 			{AcceptCharset, Req3} =
 			{AcceptCharset, Req3} =
-				cowboy_http_req:parse_header('Accept-Charset', Req2),
+				cowboy_req:parse_header('Accept-Charset', Req2),
 			case AcceptCharset of
 			case AcceptCharset of
 				undefined ->
 				undefined ->
 					set_content_type(Req3, State2#state{
 					set_content_type(Req3, State2#state{
@@ -413,7 +413,7 @@ set_content_type(Req=#http_req{meta=Meta}, State=#state{
 		undefined -> ContentType;
 		undefined -> ContentType;
 		Charset -> [ContentType, <<"; charset=">>, Charset]
 		Charset -> [ContentType, <<"; charset=">>, Charset]
 	end,
 	end,
-	{ok, Req2} = cowboy_http_req:set_resp_header(
+	{ok, Req2} = cowboy_req:set_resp_header(
 		<<"Content-Type">>, ContentType2, Req),
 		<<"Content-Type">>, ContentType2, Req),
 	encodings_provided(Req2#http_req{meta=[{charset, Charset}|Meta]}, State).
 	encodings_provided(Req2#http_req{meta=[{charset, Charset}|Meta]}, State).
 
 
@@ -468,7 +468,7 @@ variances(Req, State=#state{content_types_p=CTP,
 		[] ->
 		[] ->
 			resource_exists(Req3, State2);
 			resource_exists(Req3, State2);
 		[[<<", ">>, H]|Variances5] ->
 		[[<<", ">>, H]|Variances5] ->
-			{ok, Req4} = cowboy_http_req:set_resp_header(
+			{ok, Req4} = cowboy_req:set_resp_header(
 				<<"Variances">>, [H|Variances5], Req3),
 				<<"Variances">>, [H|Variances5], Req3),
 			resource_exists(Req4, State2)
 			resource_exists(Req4, State2)
 	end.
 	end.
@@ -478,7 +478,7 @@ resource_exists(Req, State) ->
 		fun if_match_exists/2, fun if_match_musnt_exist/2).
 		fun if_match_exists/2, fun if_match_musnt_exist/2).
 
 
 if_match_exists(Req, State) ->
 if_match_exists(Req, State) ->
-	case cowboy_http_req:parse_header('If-Match', Req) of
+	case cowboy_req:parse_header('If-Match', Req) of
 		{undefined, Req2} ->
 		{undefined, Req2} ->
 			if_unmodified_since_exists(Req2, State);
 			if_unmodified_since_exists(Req2, State);
 		{'*', Req2} ->
 		{'*', Req2} ->
@@ -496,13 +496,13 @@ if_match(Req, State, EtagsList) ->
 	end.
 	end.
 
 
 if_match_musnt_exist(Req, State) ->
 if_match_musnt_exist(Req, State) ->
-	case cowboy_http_req:header('If-Match', Req) of
+	case cowboy_req:header('If-Match', Req) of
 		{undefined, Req2} -> is_put_to_missing_resource(Req2, State);
 		{undefined, Req2} -> is_put_to_missing_resource(Req2, State);
 		{_Any, Req2} -> precondition_failed(Req2, State)
 		{_Any, Req2} -> precondition_failed(Req2, State)
 	end.
 	end.
 
 
 if_unmodified_since_exists(Req, State) ->
 if_unmodified_since_exists(Req, State) ->
-	case cowboy_http_req:parse_header('If-Unmodified-Since', Req) of
+	case cowboy_req:parse_header('If-Unmodified-Since', Req) of
 		{undefined, Req2} ->
 		{undefined, Req2} ->
 			if_none_match_exists(Req2, State);
 			if_none_match_exists(Req2, State);
 		{{error, badarg}, Req2} ->
 		{{error, badarg}, Req2} ->
@@ -520,7 +520,7 @@ if_unmodified_since(Req, State, IfUnmodifiedSince) ->
 	end.
 	end.
 
 
 if_none_match_exists(Req, State) ->
 if_none_match_exists(Req, State) ->
-	case cowboy_http_req:parse_header('If-None-Match', Req) of
+	case cowboy_req:parse_header('If-None-Match', Req) of
 		{undefined, Req2} ->
 		{undefined, Req2} ->
 			if_modified_since_exists(Req2, State);
 			if_modified_since_exists(Req2, State);
 		{'*', Req2} ->
 		{'*', Req2} ->
@@ -548,7 +548,7 @@ precondition_is_head_get(Req, State) ->
 	precondition_failed(Req, State).
 	precondition_failed(Req, State).
 
 
 if_modified_since_exists(Req, State) ->
 if_modified_since_exists(Req, State) ->
-	case cowboy_http_req:parse_header('If-Modified-Since', Req) of
+	case cowboy_req:parse_header('If-Modified-Since', Req) of
 		{undefined, Req2} ->
 		{undefined, Req2} ->
 			method(Req2, State);
 			method(Req2, State);
 		{{error, badarg}, Req2} ->
 		{{error, badarg}, Req2} ->
@@ -595,7 +595,7 @@ is_put_to_missing_resource(Req, State) ->
 moved_permanently(Req, State, OnFalse) ->
 moved_permanently(Req, State, OnFalse) ->
 	case call(Req, State, moved_permanently) of
 	case call(Req, State, moved_permanently) of
 		{{true, Location}, Req2, HandlerState} ->
 		{{true, Location}, Req2, HandlerState} ->
-			{ok, Req3} = cowboy_http_req:set_resp_header(
+			{ok, Req3} = cowboy_req:set_resp_header(
 				<<"Location">>, Location, Req2),
 				<<"Location">>, Location, Req2),
 			respond(Req3, State#state{handler_state=HandlerState}, 301);
 			respond(Req3, State#state{handler_state=HandlerState}, 301);
 		{false, Req2, HandlerState} ->
 		{false, Req2, HandlerState} ->
@@ -616,7 +616,7 @@ previously_existed(Req, State) ->
 moved_temporarily(Req, State) ->
 moved_temporarily(Req, State) ->
 	case call(Req, State, moved_temporarily) of
 	case call(Req, State, moved_temporarily) of
 		{{true, Location}, Req2, HandlerState} ->
 		{{true, Location}, Req2, HandlerState} ->
-			{ok, Req3} = cowboy_http_req:set_resp_header(
+			{ok, Req3} = cowboy_req:set_resp_header(
 				<<"Location">>, Location, Req2),
 				<<"Location">>, Location, Req2),
 			respond(Req3, State#state{handler_state=HandlerState}, 307);
 			respond(Req3, State#state{handler_state=HandlerState}, 307);
 		{false, Req2, HandlerState} ->
 		{false, Req2, HandlerState} ->
@@ -666,7 +666,7 @@ create_path(Req=#http_req{meta=Meta}, State) ->
 		{Path, Req2, HandlerState} ->
 		{Path, Req2, HandlerState} ->
 			Location = create_path_location(Req2, Path),
 			Location = create_path_location(Req2, Path),
 			State2 = State#state{handler_state=HandlerState},
 			State2 = State#state{handler_state=HandlerState},
-			{ok, Req3} = cowboy_http_req:set_resp_header(
+			{ok, Req3} = cowboy_req:set_resp_header(
 				<<"Location">>, Location, Req2),
 				<<"Location">>, Location, Req2),
 			put_resource(Req3#http_req{meta=[{put_path, Path}|Meta]},
 			put_resource(Req3#http_req{meta=[{put_path, Path}|Meta]},
 				State2, 303)
 				State2, 303)
@@ -717,7 +717,7 @@ put_resource(Req=#http_req{raw_path=RawPath, meta=Meta}, State) ->
 %% pushed to the resource in the request body. The path to the new resource
 %% pushed to the resource in the request body. The path to the new resource
 %% may be different from the request path, and is stored as request metadata.
 %% may be different from the request path, and is stored as request metadata.
 %% It is always defined past this point. It can be retrieved as demonstrated:
 %% It is always defined past this point. It can be retrieved as demonstrated:
-%%     {PutPath, Req2} = cowboy_http_req:meta(put_path, Req)
+%%     {PutPath, Req2} = cowboy_req:meta(put_path, Req)
 put_resource(Req, State, OnTrue) ->
 put_resource(Req, State, OnTrue) ->
 	case call(Req, State, content_types_accepted) of
 	case call(Req, State, content_types_accepted) of
 		no_call ->
 		no_call ->
@@ -728,7 +728,7 @@ put_resource(Req, State, OnTrue) ->
 		    CTA2 = [normalize_content_types(P) || P <- CTA],
 		    CTA2 = [normalize_content_types(P) || P <- CTA],
 			State2 = State#state{handler_state=HandlerState},
 			State2 = State#state{handler_state=HandlerState},
 			{ContentType, Req3}
 			{ContentType, Req3}
-				= cowboy_http_req:parse_header('Content-Type', Req2),
+				= cowboy_req:parse_header('Content-Type', Req2),
 			choose_content_type(Req3, State2, OnTrue, ContentType, CTA2)
 			choose_content_type(Req3, State2, OnTrue, ContentType, CTA2)
 	end.
 	end.
 
 
@@ -757,13 +757,13 @@ choose_content_type(Req, State, OnTrue, ContentType, [_Any|Tail]) ->
 %% This is easily testable because we would have set the Location
 %% This is easily testable because we would have set the Location
 %% header by this point if we did so.
 %% header by this point if we did so.
 is_new_resource(Req, State) ->
 is_new_resource(Req, State) ->
-	case cowboy_http_req:has_resp_header(<<"Location">>, Req) of
+	case cowboy_req:has_resp_header(<<"Location">>, Req) of
 		true -> respond(Req, State, 201);
 		true -> respond(Req, State, 201);
 		false -> has_resp_body(Req, State)
 		false -> has_resp_body(Req, State)
 	end.
 	end.
 
 
 has_resp_body(Req, State) ->
 has_resp_body(Req, State) ->
-	case cowboy_http_req:has_resp_body(Req) of
+	case cowboy_req:has_resp_body(Req) of
 		true -> multiple_choices(Req, State);
 		true -> multiple_choices(Req, State);
 		false -> respond(Req, State, 204)
 		false -> respond(Req, State, 204)
 	end.
 	end.
@@ -781,7 +781,7 @@ set_resp_body(Req=#http_req{method=Method},
 			Req4 = Req3;
 			Req4 = Req3;
 		LastModified ->
 		LastModified ->
 			LastModifiedStr = httpd_util:rfc1123_date(LastModified),
 			LastModifiedStr = httpd_util:rfc1123_date(LastModified),
-			{ok, Req4} = cowboy_http_req:set_resp_header(
+			{ok, Req4} = cowboy_req:set_resp_header(
 				<<"Last-Modified">>, LastModifiedStr, Req3)
 				<<"Last-Modified">>, LastModifiedStr, Req3)
 	end,
 	end,
 	{Req5, State4} = set_resp_expires(Req4, State3),
 	{Req5, State4} = set_resp_expires(Req4, State3),
@@ -792,9 +792,9 @@ set_resp_body(Req=#http_req{method=Method},
 			State5 = State4#state{handler_state=HandlerState},
 			State5 = State4#state{handler_state=HandlerState},
 			{ok, Req7} = case Body of
 			{ok, Req7} = case Body of
 				{stream, Len, Fun1} ->
 				{stream, Len, Fun1} ->
-					cowboy_http_req:set_resp_body_fun(Len, Fun1, Req6);
+					cowboy_req:set_resp_body_fun(Len, Fun1, Req6);
 				_Contents ->
 				_Contents ->
-					cowboy_http_req:set_resp_body(Body, Req6)
+					cowboy_req:set_resp_body(Body, Req6)
 			end,
 			end,
 			multiple_choices(Req7, State5)
 			multiple_choices(Req7, State5)
 	end;
 	end;
@@ -812,7 +812,7 @@ set_resp_etag(Req, State) ->
 		undefined ->
 		undefined ->
 			{Req2, State2};
 			{Req2, State2};
 		Etag ->
 		Etag ->
-			{ok, Req3} = cowboy_http_req:set_resp_header(
+			{ok, Req3} = cowboy_req:set_resp_header(
 				<<"ETag">>, encode_etag(Etag), Req2),
 				<<"ETag">>, encode_etag(Etag), Req2),
 			{Req3, State2}
 			{Req3, State2}
 	end.
 	end.
@@ -828,7 +828,7 @@ set_resp_expires(Req, State) ->
 			{Req2, State2};
 			{Req2, State2};
 		Expires ->
 		Expires ->
 			ExpiresStr = httpd_util:rfc1123_date(Expires),
 			ExpiresStr = httpd_util:rfc1123_date(Expires),
-			{ok, Req3} = cowboy_http_req:set_resp_header(
+			{ok, Req3} = cowboy_req:set_resp_header(
 				<<"Expires">>, ExpiresStr, Req2),
 				<<"Expires">>, ExpiresStr, Req2),
 			{Req3, State2}
 			{Req3, State2}
 	end.
 	end.
@@ -908,7 +908,7 @@ next(Req, State, StatusCode) when is_integer(StatusCode) ->
 	respond(Req, State, StatusCode).
 	respond(Req, State, StatusCode).
 
 
 respond(Req, State, StatusCode) ->
 respond(Req, State, StatusCode) ->
-	{ok, Req2} = cowboy_http_req:reply(StatusCode, Req),
+	{ok, Req2} = cowboy_req:reply(StatusCode, Req),
 	terminate(Req2, State).
 	terminate(Req2, State).
 
 
 terminate(Req, #state{handler=Handler, handler_state=HandlerState}) ->
 terminate(Req, #state{handler=Handler, handler_state=HandlerState}) ->

+ 2 - 2
src/cowboy_http_static.erl

@@ -231,7 +231,7 @@ rest_init(Req, Opts) ->
 	end,
 	end,
 	{Filepath, Req1} = case lists:keyfind(file, 1, Opts) of
 	{Filepath, Req1} = case lists:keyfind(file, 1, Opts) of
 		{_, Filepath2} -> {filepath_path(Filepath2), Req};
 		{_, Filepath2} -> {filepath_path(Filepath2), Req};
-		false -> cowboy_http_req:path_info(Req)
+		false -> cowboy_req:path_info(Req)
 	end,
 	end,
 	State = case check_path(Filepath) of
 	State = case check_path(Filepath) of
 		error ->
 		error ->
@@ -320,7 +320,7 @@ content_types_provided(Req, #state{filepath=Filepath,
 -spec file_contents(#http_req{}, #state{}) -> tuple().
 -spec file_contents(#http_req{}, #state{}) -> tuple().
 file_contents(Req, #state{filepath=Filepath,
 file_contents(Req, #state{filepath=Filepath,
 		fileinfo={ok, #file_info{size=Filesize}}}=State) ->
 		fileinfo={ok, #file_info{size=Filesize}}}=State) ->
-	{ok, Transport, Socket} = cowboy_http_req:transport(Req),
+	{ok, Transport, Socket} = cowboy_req:transport(Req),
 	Writefile = content_function(Transport, Socket, Filepath),
 	Writefile = content_function(Transport, Socket, Filepath),
 	{{stream, Filesize, Writefile}, Req, State}.
 	{{stream, Filesize, Writefile}, Req, State}.
 
 

+ 15 - 15
src/cowboy_http_websocket.erl

@@ -69,11 +69,11 @@ upgrade(ListenerPid, Handler, Opts, Req) ->
 -spec websocket_upgrade(#state{}, #http_req{}) -> {ok, #state{}, #http_req{}}.
 -spec websocket_upgrade(#state{}, #http_req{}) -> {ok, #state{}, #http_req{}}.
 websocket_upgrade(State, Req) ->
 websocket_upgrade(State, Req) ->
 	{ConnTokens, Req2}
 	{ConnTokens, Req2}
-		= cowboy_http_req:parse_header('Connection', Req),
+		= cowboy_req:parse_header('Connection', Req),
 	true = lists:member(<<"upgrade">>, ConnTokens),
 	true = lists:member(<<"upgrade">>, ConnTokens),
 	%% @todo Should probably send a 426 if the Upgrade header is missing.
 	%% @todo Should probably send a 426 if the Upgrade header is missing.
-	{[<<"websocket">>], Req3} = cowboy_http_req:parse_header('Upgrade', Req2),
-	{Version, Req4} = cowboy_http_req:header(<<"Sec-Websocket-Version">>, Req3),
+	{[<<"websocket">>], Req3} = cowboy_req:parse_header('Upgrade', Req2),
+	{Version, Req4} = cowboy_req:header(<<"Sec-Websocket-Version">>, Req3),
 	websocket_upgrade(Version, State, Req4).
 	websocket_upgrade(Version, State, Req4).
 
 
 %% @todo Handle the Sec-Websocket-Protocol header.
 %% @todo Handle the Sec-Websocket-Protocol header.
@@ -87,9 +87,9 @@ websocket_upgrade(State, Req) ->
 %% a reply before sending it. Therefore we calculate the challenge
 %% a reply before sending it. Therefore we calculate the challenge
 %% key only in websocket_handshake/3.
 %% key only in websocket_handshake/3.
 websocket_upgrade(undefined, State, Req=#http_req{meta=Meta}) ->
 websocket_upgrade(undefined, State, Req=#http_req{meta=Meta}) ->
-	{Origin, Req2} = cowboy_http_req:header(<<"Origin">>, Req),
-	{Key1, Req3} = cowboy_http_req:header(<<"Sec-Websocket-Key1">>, Req2),
-	{Key2, Req4} = cowboy_http_req:header(<<"Sec-Websocket-Key2">>, Req3),
+	{Origin, Req2} = cowboy_req:header(<<"Origin">>, Req),
+	{Key1, Req3} = cowboy_req:header(<<"Sec-Websocket-Key1">>, Req2),
+	{Key2, Req4} = cowboy_req:header(<<"Sec-Websocket-Key2">>, Req3),
 	false = lists:member(undefined, [Origin, Key1, Key2]),
 	false = lists:member(undefined, [Origin, Key1, Key2]),
 	EOP = binary:compile_pattern(<< 255 >>),
 	EOP = binary:compile_pattern(<< 255 >>),
 	{ok, State#state{version=0, origin=Origin, challenge={Key1, Key2},
 	{ok, State#state{version=0, origin=Origin, challenge={Key1, Key2},
@@ -98,7 +98,7 @@ websocket_upgrade(undefined, State, Req=#http_req{meta=Meta}) ->
 websocket_upgrade(Version, State, Req=#http_req{meta=Meta})
 websocket_upgrade(Version, State, Req=#http_req{meta=Meta})
 		when Version =:= <<"7">>; Version =:= <<"8">>;
 		when Version =:= <<"7">>; Version =:= <<"8">>;
 			Version =:= <<"13">> ->
 			Version =:= <<"13">> ->
-	{Key, Req2} = cowboy_http_req:header(<<"Sec-Websocket-Key">>, Req),
+	{Key, Req2} = cowboy_req:header(<<"Sec-Websocket-Key">>, Req),
 	false = Key =:= undefined,
 	false = Key =:= undefined,
 	Challenge = hybi_challenge(Key),
 	Challenge = hybi_challenge(Key),
 	IntVersion = list_to_integer(binary_to_list(Version)),
 	IntVersion = list_to_integer(binary_to_list(Version)),
@@ -134,7 +134,7 @@ handler_init(State=#state{handler=Handler, opts=Opts},
 
 
 -spec upgrade_error(#http_req{}) -> closed.
 -spec upgrade_error(#http_req{}) -> closed.
 upgrade_error(Req) ->
 upgrade_error(Req) ->
-	{ok, _Req2} = cowboy_http_req:reply(400, [], [],
+	{ok, _Req2} = cowboy_req:reply(400, [], [],
 		Req#http_req{resp_state=waiting}),
 		Req#http_req{resp_state=waiting}),
 	closed.
 	closed.
 
 
@@ -143,7 +143,7 @@ upgrade_error(Req) ->
 upgrade_denied(#http_req{resp_state=done}) ->
 upgrade_denied(#http_req{resp_state=done}) ->
 	closed;
 	closed;
 upgrade_denied(Req=#http_req{resp_state=waiting}) ->
 upgrade_denied(Req=#http_req{resp_state=waiting}) ->
-	{ok, _Req2} = cowboy_http_req:reply(400, [], [], Req),
+	{ok, _Req2} = cowboy_req:reply(400, [], [], Req),
 	closed;
 	closed;
 upgrade_denied(#http_req{method='HEAD', resp_state=chunks}) ->
 upgrade_denied(#http_req{method='HEAD', resp_state=chunks}) ->
 	closed;
 	closed;
@@ -158,24 +158,24 @@ websocket_handshake(State=#state{version=0, origin=Origin,
 		transport=Transport, raw_host=Host, port=Port,
 		transport=Transport, raw_host=Host, port=Port,
 		raw_path=Path, raw_qs=QS}, HandlerState) ->
 		raw_path=Path, raw_qs=QS}, HandlerState) ->
 	Location = hixie76_location(Transport:name(), Host, Port, Path, QS),
 	Location = hixie76_location(Transport:name(), Host, Port, Path, QS),
-	{ok, Req2} = cowboy_http_req:upgrade_reply(
+	{ok, Req2} = cowboy_req:upgrade_reply(
 		<<"101 WebSocket Protocol Handshake">>,
 		<<"101 WebSocket Protocol Handshake">>,
 		[{<<"Upgrade">>, <<"WebSocket">>},
 		[{<<"Upgrade">>, <<"WebSocket">>},
 		 {<<"Sec-Websocket-Location">>, Location},
 		 {<<"Sec-Websocket-Location">>, Location},
 		 {<<"Sec-Websocket-Origin">>, Origin}],
 		 {<<"Sec-Websocket-Origin">>, Origin}],
 		Req#http_req{resp_state=waiting}),
 		Req#http_req{resp_state=waiting}),
 	%% Flush the resp_sent message before moving on.
 	%% Flush the resp_sent message before moving on.
-	receive {cowboy_http_req, resp_sent} -> ok after 0 -> ok end,
+	receive {cowboy_req, resp_sent} -> ok after 0 -> ok end,
 	%% We replied with a proper response. Proxies should be happy enough,
 	%% We replied with a proper response. Proxies should be happy enough,
 	%% we can now read the 8 last bytes of the challenge keys and send
 	%% we can now read the 8 last bytes of the challenge keys and send
 	%% the challenge response directly to the socket.
 	%% the challenge response directly to the socket.
 	%%
 	%%
 	%% We use a trick here to read exactly 8 bytes of the body regardless
 	%% We use a trick here to read exactly 8 bytes of the body regardless
 	%% of what's in the buffer.
 	%% of what's in the buffer.
-	{ok, Req3} = cowboy_http_req:init_stream(
+	{ok, Req3} = cowboy_req:init_stream(
 		fun cowboy_http:te_identity/2, {0, 8},
 		fun cowboy_http:te_identity/2, {0, 8},
 		fun cowboy_http:ce_identity/1, Req2),
 		fun cowboy_http:ce_identity/1, Req2),
-	case cowboy_http_req:body(Req3) of
+	case cowboy_req:body(Req3) of
 		{ok, Key3, Req4} ->
 		{ok, Key3, Req4} ->
 			Challenge = hixie76_challenge(Key1, Key2, Key3),
 			Challenge = hixie76_challenge(Key1, Key2, Key3),
 			Transport:send(Socket, Challenge),
 			Transport:send(Socket, Challenge),
@@ -186,13 +186,13 @@ websocket_handshake(State=#state{version=0, origin=Origin,
 	end;
 	end;
 websocket_handshake(State=#state{challenge=Challenge},
 websocket_handshake(State=#state{challenge=Challenge},
 		Req=#http_req{transport=Transport}, HandlerState) ->
 		Req=#http_req{transport=Transport}, HandlerState) ->
-	{ok, Req2} = cowboy_http_req:upgrade_reply(
+	{ok, Req2} = cowboy_req:upgrade_reply(
 		101,
 		101,
 		[{<<"Upgrade">>, <<"websocket">>},
 		[{<<"Upgrade">>, <<"websocket">>},
 		 {<<"Sec-Websocket-Accept">>, Challenge}],
 		 {<<"Sec-Websocket-Accept">>, Challenge}],
 		Req#http_req{resp_state=waiting}),
 		Req#http_req{resp_state=waiting}),
 	%% Flush the resp_sent message before moving on.
 	%% Flush the resp_sent message before moving on.
-	receive {cowboy_http_req, resp_sent} -> ok after 0 -> ok end,
+	receive {cowboy_req, resp_sent} -> ok after 0 -> ok end,
 	handler_before_loop(State#state{messages=Transport:messages()},
 	handler_before_loop(State#state{messages=Transport:messages()},
 		Req2, HandlerState, <<>>).
 		Req2, HandlerState, <<>>).
 
 

+ 7 - 7
src/cowboy_protocol.erl

@@ -208,7 +208,7 @@ header({http_header, _I, 'Connection', _R, Connection},
 		when Keepalive < MaxKeepalive ->
 		when Keepalive < MaxKeepalive ->
 	Req2 = Req#http_req{headers=[{'Connection', Connection}|Headers]},
 	Req2 = Req#http_req{headers=[{'Connection', Connection}|Headers]},
 	{ConnTokens, Req3}
 	{ConnTokens, Req3}
-		= cowboy_http_req:parse_header('Connection', Req2),
+		= cowboy_req:parse_header('Connection', Req2),
 	ConnAtom = cowboy_http:connection_to_atom(ConnTokens),
 	ConnAtom = cowboy_http:connection_to_atom(ConnTokens),
 	parse_header(Req3#http_req{connection=ConnAtom}, State);
 	parse_header(Req3#http_req{connection=ConnAtom}, State);
 header({http_header, _I, Field, _R, Value}, Req, State) ->
 header({http_header, _I, Field, _R, Value}, Req, State) ->
@@ -399,7 +399,7 @@ next_request(Req=#http_req{connection=Conn}, State=#state{
 	RespRes = ensure_response(Req),
 	RespRes = ensure_response(Req),
 	{BodyRes, Buffer} = ensure_body_processed(Req),
 	{BodyRes, Buffer} = ensure_body_processed(Req),
 	%% Flush the resp_sent message before moving on.
 	%% Flush the resp_sent message before moving on.
-	receive {cowboy_http_req, resp_sent} -> ok after 0 -> ok end,
+	receive {cowboy_req, resp_sent} -> ok after 0 -> ok end,
 	case {HandlerRes, BodyRes, RespRes, Conn} of
 	case {HandlerRes, BodyRes, RespRes, Conn} of
 		{ok, ok, ok, keepalive} ->
 		{ok, ok, ok, keepalive} ->
 			?MODULE:parse_request(State#state{
 			?MODULE:parse_request(State#state{
@@ -413,12 +413,12 @@ next_request(Req=#http_req{connection=Conn}, State=#state{
 ensure_body_processed(#http_req{body_state=done, buffer=Buffer}) ->
 ensure_body_processed(#http_req{body_state=done, buffer=Buffer}) ->
 	{ok, Buffer};
 	{ok, Buffer};
 ensure_body_processed(Req=#http_req{body_state=waiting}) ->
 ensure_body_processed(Req=#http_req{body_state=waiting}) ->
-	case cowboy_http_req:skip_body(Req) of
+	case cowboy_req:skip_body(Req) of
 		{ok, Req2} -> {ok, Req2#http_req.buffer};
 		{ok, Req2} -> {ok, Req2#http_req.buffer};
 		{error, _Reason} -> {close, <<>>}
 		{error, _Reason} -> {close, <<>>}
 	end;
 	end;
 ensure_body_processed(Req=#http_req{body_state={multipart, _, _}}) ->
 ensure_body_processed(Req=#http_req{body_state={multipart, _, _}}) ->
-	{ok, Req2} = cowboy_http_req:multipart_skip(Req),
+	{ok, Req2} = cowboy_req:multipart_skip(Req),
 	ensure_body_processed(Req2).
 	ensure_body_processed(Req2).
 
 
 -spec ensure_response(#http_req{}) -> ok.
 -spec ensure_response(#http_req{}) -> ok.
@@ -428,7 +428,7 @@ ensure_response(#http_req{resp_state=done}) ->
 %% No response has been sent but everything apparently went fine.
 %% No response has been sent but everything apparently went fine.
 %% Reply with 204 No Content to indicate this.
 %% Reply with 204 No Content to indicate this.
 ensure_response(Req=#http_req{resp_state=waiting}) ->
 ensure_response(Req=#http_req{resp_state=waiting}) ->
-	_ = cowboy_http_req:reply(204, [], [], Req),
+	_ = cowboy_req:reply(204, [], [], Req),
 	ok;
 	ok;
 %% Terminate the chunked body for HTTP/1.1 only.
 %% Terminate the chunked body for HTTP/1.1 only.
 ensure_response(#http_req{method='HEAD', resp_state=chunks}) ->
 ensure_response(#http_req{method='HEAD', resp_state=chunks}) ->
@@ -445,9 +445,9 @@ ensure_response(#http_req{socket=Socket, transport=Transport,
 error_terminate(Code, State=#state{socket=Socket, transport=Transport,
 error_terminate(Code, State=#state{socket=Socket, transport=Transport,
 		onresponse=OnResponse}) ->
 		onresponse=OnResponse}) ->
 	receive
 	receive
-		{cowboy_http_req, resp_sent} -> ok
+		{cowboy_req, resp_sent} -> ok
 	after 0 ->
 	after 0 ->
-		_ = cowboy_http_req:reply(Code, #http_req{
+		_ = cowboy_req:reply(Code, #http_req{
 			socket=Socket, transport=Transport, onresponse=OnResponse,
 			socket=Socket, transport=Transport, onresponse=OnResponse,
 			connection=close, pid=self(), resp_state=waiting}),
 			connection=close, pid=self(), resp_state=waiting}),
 		ok
 		ok

+ 3 - 3
src/cowboy_http_req.erl → src/cowboy_req.erl

@@ -19,7 +19,7 @@
 %% It should always be used instead of the one used in your function call
 %% It should always be used instead of the one used in your function call
 %% because it keeps the state of the request. It also allows Cowboy to do
 %% because it keeps the state of the request. It also allows Cowboy to do
 %% some lazy evaluation and cache results where possible.
 %% some lazy evaluation and cache results where possible.
--module(cowboy_http_req).
+-module(cowboy_req).
 
 
 %% Request API.
 %% Request API.
 -export([method/1]).
 -export([method/1]).
@@ -711,7 +711,7 @@ set_resp_body(Body, Req) ->
 %% if the response is later sent using anything other than `reply/2' or
 %% if the response is later sent using anything other than `reply/2' or
 %% `reply/3'.
 %% `reply/3'.
 %%
 %%
-%% @see cowboy_http_req:transport/1.
+%% @see cowboy_req:transport/1.
 -spec set_resp_body_fun(non_neg_integer(), fun(() -> {sent, non_neg_integer()}),
 -spec set_resp_body_fun(non_neg_integer(), fun(() -> {sent, non_neg_integer()}),
 		#http_req{}) -> {ok, #http_req{}}.
 		#http_req{}) -> {ok, #http_req{}}.
 set_resp_body_fun(StreamLen, StreamFun, Req) ->
 set_resp_body_fun(StreamLen, StreamFun, Req) ->
@@ -775,7 +775,7 @@ chunked_reply(Status, Req) ->
 	chunked_reply(Status, [], Req).
 	chunked_reply(Status, [], Req).
 
 
 %% @doc Initiate the sending of a chunked reply to the client.
 %% @doc Initiate the sending of a chunked reply to the client.
-%% @see cowboy_http_req:chunk/2
+%% @see cowboy_req:chunk/2
 -spec chunked_reply(cowboy_http:status(), cowboy_http:headers(), #http_req{})
 -spec chunked_reply(cowboy_http:status(), cowboy_http:headers(), #http_req{})
 	-> {ok, #http_req{}}.
 	-> {ok, #http_req{}}.
 chunked_reply(Status, Headers, Req=#http_req{
 chunked_reply(Status, Headers, Req=#http_req{

+ 3 - 3
test/chunked_handler.erl

@@ -8,9 +8,9 @@ init({_Transport, http}, Req, _Opts) ->
 	{ok, Req, undefined}.
 	{ok, Req, undefined}.
 
 
 handle(Req, State) ->
 handle(Req, State) ->
-	{ok, Req2} = cowboy_http_req:chunked_reply(200, Req),
-	cowboy_http_req:chunk("chunked_handler\r\n", Req2),
-	cowboy_http_req:chunk("works fine!", Req2),
+	{ok, Req2} = cowboy_req:chunked_reply(200, Req),
+	cowboy_req:chunk("chunked_handler\r\n", Req2),
+	cowboy_req:chunk("works fine!", Req2),
 	{ok, Req2, State}.
 	{ok, Req2, State}.
 
 
 terminate(_Req, _State) ->
 terminate(_Req, _State) ->

+ 4 - 4
test/http_SUITE.erl

@@ -597,13 +597,13 @@ onrequest_reply(Config) ->
 
 
 %% Hook for the above onrequest tests.
 %% Hook for the above onrequest tests.
 onrequest_hook(Req) ->
 onrequest_hook(Req) ->
-	case cowboy_http_req:qs_val(<<"reply">>, Req) of
+	case cowboy_req:qs_val(<<"reply">>, Req) of
 		{undefined, Req2} ->
 		{undefined, Req2} ->
-			{ok, Req3} = cowboy_http_req:set_resp_header(
+			{ok, Req3} = cowboy_req:set_resp_header(
 				'Server', <<"Serenity">>, Req2),
 				'Server', <<"Serenity">>, Req2),
 			Req3;
 			Req3;
 		{_, Req2} ->
 		{_, Req2} ->
-			{ok, Req3} = cowboy_http_req:reply(
+			{ok, Req3} = cowboy_req:reply(
 				200, [], <<"replied!">>, Req2),
 				200, [], <<"replied!">>, Req2),
 			Req3
 			Req3
 	end.
 	end.
@@ -626,7 +626,7 @@ onresponse_reply(Config) ->
 
 
 %% Hook for the above onresponse tests.
 %% Hook for the above onresponse tests.
 onresponse_hook(_, Headers, Req) ->
 onresponse_hook(_, Headers, Req) ->
-	{ok, Req2} = cowboy_http_req:reply(
+	{ok, Req2} = cowboy_req:reply(
 		<<"777 Lucky">>, [{<<"x-hook">>, <<"onresponse">>}|Headers], Req),
 		<<"777 Lucky">>, [{<<"x-hook">>, <<"onresponse">>}|Headers], Req),
 	Req2.
 	Req2.
 
 

+ 1 - 1
test/http_handler.erl

@@ -12,7 +12,7 @@ init({_Transport, http}, Req, Opts) ->
 	{ok, Req, #state{headers=Headers, body=Body}}.
 	{ok, Req, #state{headers=Headers, body=Body}}.
 
 
 handle(Req, State=#state{headers=Headers, body=Body}) ->
 handle(Req, State=#state{headers=Headers, body=Body}) ->
-	{ok, Req2} = cowboy_http_req:reply(200, Headers, Body, Req),
+	{ok, Req2} = cowboy_req:reply(200, Headers, Body, Req),
 	{ok, Req2, State}.
 	{ok, Req2, State}.
 
 
 terminate(_Req, _State) ->
 terminate(_Req, _State) ->

+ 4 - 4
test/http_handler_echo_body.erl

@@ -8,11 +8,11 @@ init({_, http}, Req, _) ->
 	{ok, Req, undefined}.
 	{ok, Req, undefined}.
 
 
 handle(Req, State) ->
 handle(Req, State) ->
-	{true, Req1} = cowboy_http_req:has_body(Req),
-	{ok, Body, Req2} = cowboy_http_req:body(Req1),
-	{Size, Req3} = cowboy_http_req:body_length(Req2),
+	{true, Req1} = cowboy_req:has_body(Req),
+	{ok, Body, Req2} = cowboy_req:body(Req1),
+	{Size, Req3} = cowboy_req:body_length(Req2),
 	Size = byte_size(Body),
 	Size = byte_size(Body),
-	{ok, Req4} = cowboy_http_req:reply(200, [], Body, Req3),
+	{ok, Req4} = cowboy_req:reply(200, [], Body, Req3),
 	{ok, Req4, State}.
 	{ok, Req4, State}.
 
 
 terminate(_, _) ->
 terminate(_, _) ->

+ 4 - 4
test/http_handler_errors.erl

@@ -5,18 +5,18 @@
 -export([init/3, handle/2, terminate/2]).
 -export([init/3, handle/2, terminate/2]).
 
 
 init({_Transport, http}, Req, _Opts) ->
 init({_Transport, http}, Req, _Opts) ->
-    {Case, Req1} = cowboy_http_req:qs_val(<<"case">>, Req),
+    {Case, Req1} = cowboy_req:qs_val(<<"case">>, Req),
     case_init(Case, Req1).
     case_init(Case, Req1).
 
 
 case_init(<<"init_before_reply">> = Case, _Req) ->
 case_init(<<"init_before_reply">> = Case, _Req) ->
     erlang:error(Case);
     erlang:error(Case);
 
 
 case_init(<<"init_after_reply">> = Case, Req) ->
 case_init(<<"init_after_reply">> = Case, Req) ->
-    {ok, _Req1} = cowboy_http_req:reply(200, [], "http_handler_crashes", Req),
+    {ok, _Req1} = cowboy_req:reply(200, [], "http_handler_crashes", Req),
     erlang:error(Case);
     erlang:error(Case);
 
 
 case_init(<<"init_reply_handle_error">> = Case, Req) ->
 case_init(<<"init_reply_handle_error">> = Case, Req) ->
-    {ok, Req1} = cowboy_http_req:reply(200, [], "http_handler_crashes", Req),
+    {ok, Req1} = cowboy_req:reply(200, [], "http_handler_crashes", Req),
     {ok, Req1, Case};
     {ok, Req1, Case};
 
 
 case_init(<<"handle_before_reply">> = Case, Req) ->
 case_init(<<"handle_before_reply">> = Case, Req) ->
@@ -33,7 +33,7 @@ handle(_Req, <<"handle_before_reply">> = Case) ->
     erlang:error(Case);
     erlang:error(Case);
 
 
 handle(Req, <<"handle_after_reply">> = Case) ->
 handle(Req, <<"handle_after_reply">> = Case) ->
-    {ok, _Req1} = cowboy_http_req:reply(200, [], "http_handler_crashes", Req),
+    {ok, _Req1} = cowboy_req:reply(200, [], "http_handler_crashes", Req),
     erlang:error(Case).
     erlang:error(Case).
 
 
 terminate(_Req, _State) ->
 terminate(_Req, _State) ->

+ 2 - 2
test/http_handler_init_shutdown.erl

@@ -5,12 +5,12 @@
 -export([init/3, handle/2, terminate/2]).
 -export([init/3, handle/2, terminate/2]).
 
 
 init({_Transport, http}, Req, _Opts) ->
 init({_Transport, http}, Req, _Opts) ->
-	{ok, Req2} = cowboy_http_req:reply(<<"666 Init Shutdown Testing">>,
+	{ok, Req2} = cowboy_req:reply(<<"666 Init Shutdown Testing">>,
 		[{'Connection', <<"close">>}], Req),
 		[{'Connection', <<"close">>}], Req),
 	{shutdown, Req2, undefined}.
 	{shutdown, Req2, undefined}.
 
 
 handle(Req, State) ->
 handle(Req, State) ->
-	{ok, Req2} = cowboy_http_req:reply(200, [], "Hello world!", Req),
+	{ok, Req2} = cowboy_req:reply(200, [], "Hello world!", Req),
 	{ok, Req2, State}.
 	{ok, Req2, State}.
 
 
 terminate(_Req, _State) ->
 terminate(_Req, _State) ->

+ 1 - 1
test/http_handler_long_polling.erl

@@ -12,7 +12,7 @@ handle(_Req, _State) ->
 	exit(badarg).
 	exit(badarg).
 
 
 info(timeout, Req, 0) ->
 info(timeout, Req, 0) ->
-	{ok, Req2} = cowboy_http_req:reply(102, Req),
+	{ok, Req2} = cowboy_req:reply(102, Req),
 	{ok, Req2, 0};
 	{ok, Req2, 0};
 info(timeout, Req, State) ->
 info(timeout, Req, State) ->
 	erlang:send_after(500, self(), timeout),
 	erlang:send_after(500, self(), timeout),

+ 1 - 1
test/http_handler_loop_timeout.erl

@@ -9,7 +9,7 @@ init({_, http}, Req, _) ->
 	{loop, Req, undefined, 500, hibernate}.
 	{loop, Req, undefined, 500, hibernate}.
 
 
 info(error_timeout, Req, State) ->
 info(error_timeout, Req, State) ->
-	{ok, Req2} = cowboy_http_req:reply(500, Req),
+	{ok, Req2} = cowboy_req:reply(500, Req),
 	{ok, Req2, State}.
 	{ok, Req2, State}.
 
 
 terminate(_, _) ->
 terminate(_, _) ->

+ 2 - 2
test/http_handler_multipart.erl

@@ -9,14 +9,14 @@ init({_Transport, http}, Req, []) ->
 
 
 handle(Req, State) ->
 handle(Req, State) ->
 	{Result, Req2} = acc_multipart(Req, []),
 	{Result, Req2} = acc_multipart(Req, []),
-	{ok, Req3} = cowboy_http_req:reply(200, [], term_to_binary(Result), Req2),
+	{ok, Req3} = cowboy_req:reply(200, [], term_to_binary(Result), Req2),
 	{ok, Req3, State}.
 	{ok, Req3, State}.
 
 
 terminate(_Req, _State) ->
 terminate(_Req, _State) ->
 	ok.
 	ok.
 
 
 acc_multipart(Req, Acc) ->
 acc_multipart(Req, Acc) ->
-	{Result, Req2} = cowboy_http_req:multipart_data(Req),
+	{Result, Req2} = cowboy_req:multipart_data(Req),
 	acc_multipart(Req2, Acc, Result).
 	acc_multipart(Req2, Acc, Result).
 
 
 acc_multipart(Req, Acc, {headers, Headers}) ->
 acc_multipart(Req, Acc, {headers, Headers}) ->

+ 7 - 7
test/http_handler_set_resp.erl

@@ -8,23 +8,23 @@ init({_Transport, http}, Req, Opts) ->
 	Headers = proplists:get_value(headers, Opts, []),
 	Headers = proplists:get_value(headers, Opts, []),
 	Body = proplists:get_value(body, Opts, <<"http_handler_set_resp">>),
 	Body = proplists:get_value(body, Opts, <<"http_handler_set_resp">>),
 	{ok, Req2} = lists:foldl(fun({Name, Value}, {ok, R}) ->
 	{ok, Req2} = lists:foldl(fun({Name, Value}, {ok, R}) ->
-		cowboy_http_req:set_resp_header(Name, Value, R)
+		cowboy_req:set_resp_header(Name, Value, R)
 	end, {ok, Req}, Headers),
 	end, {ok, Req}, Headers),
-	{ok, Req3} = cowboy_http_req:set_resp_body(Body, Req2),
-	{ok, Req4} = cowboy_http_req:set_resp_header(
+	{ok, Req3} = cowboy_req:set_resp_body(Body, Req2),
+	{ok, Req4} = cowboy_req:set_resp_header(
 		<<"X-Cowboy-Test">>, <<"ok">>, Req3),
 		<<"X-Cowboy-Test">>, <<"ok">>, Req3),
-	{ok, Req5} = cowboy_http_req:set_resp_cookie(
+	{ok, Req5} = cowboy_req:set_resp_cookie(
 		<<"cake">>, <<"lie">>, [], Req4),
 		<<"cake">>, <<"lie">>, [], Req4),
 	{ok, Req5, undefined}.
 	{ok, Req5, undefined}.
 
 
 handle(Req, State) ->
 handle(Req, State) ->
-	case cowboy_http_req:has_resp_header(<<"X-Cowboy-Test">>, Req) of
+	case cowboy_req:has_resp_header(<<"X-Cowboy-Test">>, Req) of
 		false -> {ok, Req, State};
 		false -> {ok, Req, State};
 		true ->
 		true ->
-			case cowboy_http_req:has_resp_body(Req) of
+			case cowboy_req:has_resp_body(Req) of
 				false -> {ok, Req, State};
 				false -> {ok, Req, State};
 				true ->
 				true ->
-					{ok, Req2} = cowboy_http_req:reply(200, Req),
+					{ok, Req2} = cowboy_req:reply(200, Req),
 					{ok, Req2, State}
 					{ok, Req2, State}
 			end
 			end
 	end.
 	end.

+ 3 - 3
test/http_handler_stream_body.erl

@@ -13,11 +13,11 @@ init({_Transport, http}, Req, Opts) ->
 	{ok, Req, #state{headers=Headers, body=Body, reply=Reply}}.
 	{ok, Req, #state{headers=Headers, body=Body, reply=Reply}}.
 
 
 handle(Req, State=#state{headers=_Headers, body=Body, reply=set_resp}) ->
 handle(Req, State=#state{headers=_Headers, body=Body, reply=set_resp}) ->
-	{ok, Transport, Socket} = cowboy_http_req:transport(Req),
+	{ok, Transport, Socket} = cowboy_req:transport(Req),
 	SFun = fun() -> Transport:send(Socket, Body), sent end,
 	SFun = fun() -> Transport:send(Socket, Body), sent end,
 	SLen = iolist_size(Body),
 	SLen = iolist_size(Body),
-	{ok, Req2} = cowboy_http_req:set_resp_body_fun(SLen, SFun, Req),
-	{ok, Req3} = cowboy_http_req:reply(200, Req2),
+	{ok, Req2} = cowboy_req:set_resp_body_fun(SLen, SFun, Req),
+	{ok, Req3} = cowboy_req:reply(200, Req2),
 	{ok, Req3, State}.
 	{ok, Req3, State}.
 
 
 terminate(_Req, _State) ->
 terminate(_Req, _State) ->

+ 1 - 1
test/rest_forbidden_resource.erl

@@ -27,7 +27,7 @@ post_is_create(Req, State) ->
 	{true, Req, State}.
 	{true, Req, State}.
 
 
 create_path(Req, State) ->
 create_path(Req, State) ->
-	{Path, Req2} = cowboy_http_req:raw_path(Req),
+	{Path, Req2} = cowboy_req:raw_path(Req),
 	{Path, Req2, State}.
 	{Path, Req2, State}.
 
 
 to_text(Req, State) ->
 to_text(Req, State) ->

+ 1 - 1
test/rest_resource_etags.erl

@@ -5,7 +5,7 @@ init(_Transport, _Req, _Opts) ->
 	{upgrade, protocol, cowboy_http_rest}.
 	{upgrade, protocol, cowboy_http_rest}.
 
 
 generate_etag(Req, State) ->
 generate_etag(Req, State) ->
-	case cowboy_http_req:qs_val(<<"type">>, Req) of
+	case cowboy_req:qs_val(<<"type">>, Req) of
 		%% Correct return values from generate_etag/2.
 		%% Correct return values from generate_etag/2.
 		{<<"tuple-weak">>, Req2} ->
 		{<<"tuple-weak">>, Req2} ->
 			{{weak, <<"etag-header-value">>}, Req2, State};
 			{{weak, <<"etag-header-value">>}, Req2, State};

+ 1 - 1
test/websocket_echo_handler.erl

@@ -17,7 +17,7 @@ terminate(_Req, _State) ->
 	exit(badarg).
 	exit(badarg).
 
 
 websocket_init(_TransportName, Req, _Opts) ->
 websocket_init(_TransportName, Req, _Opts) ->
-	Req2 = cowboy_http_req:compact(Req),
+	Req2 = cowboy_req:compact(Req),
 	{ok, Req2, undefined}.
 	{ok, Req2, undefined}.
 
 
 websocket_handle({text, Data}, Req, State) ->
 websocket_handle({text, Data}, Req, State) ->

+ 1 - 1
test/websocket_handler.erl

@@ -18,7 +18,7 @@ terminate(_Req, _State) ->
 
 
 websocket_init(_TransportName, Req, _Opts) ->
 websocket_init(_TransportName, Req, _Opts) ->
 	erlang:start_timer(1000, self(), <<"websocket_init">>),
 	erlang:start_timer(1000, self(), <<"websocket_init">>),
-	Req2 = cowboy_http_req:compact(Req),
+	Req2 = cowboy_req:compact(Req),
 	{ok, Req2, undefined}.
 	{ok, Req2, undefined}.
 
 
 websocket_handle({text, Data}, Req, State) ->
 websocket_handle({text, Data}, Req, State) ->

+ 1 - 1
test/websocket_handler_init_shutdown.erl

@@ -17,7 +17,7 @@ terminate(_Req, _State) ->
 	exit(badarg).
 	exit(badarg).
 
 
 websocket_init(_TransportName, Req, _Opts) ->
 websocket_init(_TransportName, Req, _Opts) ->
-	{ok, Req2} = cowboy_http_req:reply(403, Req),
+	{ok, Req2} = cowboy_req:reply(403, Req),
 	{shutdown, Req2}.
 	{shutdown, Req2}.
 
 
 websocket_handle(_Frame, _Req, _State) ->
 websocket_handle(_Frame, _Req, _State) ->