diff options
author | YAMAMOTO Takashi <[email protected]> | 2013-08-25 02:13:53 +0900 |
---|---|---|
committer | YAMAMOTO Takashi <[email protected]> | 2013-09-03 02:59:12 +0900 |
commit | d2adbf3de66f15dc0b654c76ee7bee7bd9c8c778 (patch) | |
tree | 7fef2f7d4bed4215eb83bdd1e1117f6315ffd142 /test/http_SUITE_data/http_req_attr.erl | |
parent | 201c53cb9f8217d497fb7acae2fa7d64f04f4022 (diff) | |
download | cowboy-d2adbf3de66f15dc0b654c76ee7bee7bd9c8c778.tar.gz cowboy-d2adbf3de66f15dc0b654c76ee7bee7bd9c8c778.tar.bz2 cowboy-d2adbf3de66f15dc0b654c76ee7bee7bd9c8c778.zip |
add some tests for Host header parser
Diffstat (limited to 'test/http_SUITE_data/http_req_attr.erl')
-rw-r--r-- | test/http_SUITE_data/http_req_attr.erl | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test/http_SUITE_data/http_req_attr.erl b/test/http_SUITE_data/http_req_attr.erl new file mode 100644 index 0000000..eb5e70e --- /dev/null +++ b/test/http_SUITE_data/http_req_attr.erl @@ -0,0 +1,19 @@ +%% Feel free to use, reuse and abuse the code in this file. + +-module(http_req_attr). +-behaviour(cowboy_http_handler). +-export([init/3, handle/2, terminate/3]). + +init({_, http}, Req, _) -> + {Attr, Req2} = cowboy_req:qs_val(<<"attr">>, Req), + {ok, Req2, Attr}. + +handle(Req, <<"host_and_port">> = Attr) -> + {Host, Req2} = cowboy_req:host(Req), + {Port, Req3} = cowboy_req:port(Req2), + Value = [Host, "\n", integer_to_list(Port)], + {ok, Req4} = cowboy_req:reply(200, [], Value, Req3), + {ok, Req4, Attr}. + +terminate(_, _, _) -> + ok. |