diff options
-rw-r--r-- | Makefile | 13 | ||||
-rw-r--r-- | guide/rest_handlers.md | 13 | ||||
-rw-r--r-- | guide/static_handlers.md | 32 | ||||
-rw-r--r-- | guide/toc.md | 1 | ||||
-rw-r--r-- | src/cowboy_http.erl | 11 | ||||
-rw-r--r-- | src/cowboy_req.erl | 3 | ||||
-rw-r--r-- | test/autobahn_SUITE.erl | 2 | ||||
-rw-r--r-- | test/autobahn_SUITE_data/autobahn_echo.erl | 26 | ||||
-rwxr-xr-x | test/autobahn_SUITE_data/test.py | 11 | ||||
-rw-r--r-- | test/http_SUITE.erl | 36 | ||||
-rw-r--r-- | test/http_SUITE_data/http_body_qs.erl (renamed from test/http_handler_body_qs.erl) | 2 | ||||
-rw-r--r-- | test/http_SUITE_data/http_chunked.erl (renamed from test/chunked_handler.erl) | 2 | ||||
-rw-r--r-- | test/http_SUITE_data/http_echo_body.erl (renamed from test/http_handler_echo_body.erl) | 2 | ||||
-rw-r--r-- | test/http_SUITE_data/http_errors.erl (renamed from test/http_handler_errors.erl) | 2 | ||||
-rw-r--r-- | test/http_SUITE_data/http_handler.erl (renamed from test/http_handler.erl) | 0 | ||||
-rw-r--r-- | test/http_SUITE_data/http_init_shutdown.erl (renamed from test/http_handler_init_shutdown.erl) | 2 | ||||
-rw-r--r-- | test/http_SUITE_data/http_long_polling.erl (renamed from test/http_handler_long_polling.erl) | 2 | ||||
-rw-r--r-- | test/http_SUITE_data/http_loop_recv.erl (renamed from test/http_handler_loop_recv.erl) | 2 | ||||
-rw-r--r-- | test/http_SUITE_data/http_loop_timeout.erl (renamed from test/http_handler_loop_timeout.erl) | 2 | ||||
-rw-r--r-- | test/http_SUITE_data/http_multipart.erl (renamed from test/http_handler_multipart.erl) | 2 | ||||
-rw-r--r-- | test/http_SUITE_data/http_set_resp.erl (renamed from test/http_handler_set_resp.erl) | 2 | ||||
-rw-r--r-- | test/http_SUITE_data/http_stream_body.erl (renamed from test/http_handler_stream_body.erl) | 2 | ||||
-rw-r--r-- | test/http_SUITE_data/rest_empty_resource.erl (renamed from test/rest_empty_resource.erl) | 0 | ||||
-rw-r--r-- | test/http_SUITE_data/rest_expires.erl (renamed from test/rest_expires.erl) | 0 | ||||
-rw-r--r-- | test/http_SUITE_data/rest_forbidden_resource.erl (renamed from test/rest_forbidden_resource.erl) | 0 | ||||
-rw-r--r-- | test/http_SUITE_data/rest_missing_callbacks.erl (renamed from test/rest_missing_callbacks.erl) | 0 | ||||
-rw-r--r-- | test/http_SUITE_data/rest_nodelete_resource.erl (renamed from test/rest_nodelete_resource.erl) | 0 | ||||
-rw-r--r-- | test/http_SUITE_data/rest_param_all.erl (renamed from test/rest_param_all.erl) | 0 | ||||
-rw-r--r-- | test/http_SUITE_data/rest_patch_resource.erl (renamed from test/rest_patch_resource.erl) | 0 | ||||
-rw-r--r-- | test/http_SUITE_data/rest_resource_etags.erl (renamed from test/rest_resource_etags.erl) | 0 | ||||
-rw-r--r-- | test/http_SUITE_data/rest_simple_resource.erl (renamed from test/rest_simple_resource.erl) | 0 | ||||
-rw-r--r-- | test/http_SUITE_data/ssl/cert.pem (renamed from test/http_SUITE_data/cert.pem) | 0 | ||||
-rw-r--r-- | test/http_SUITE_data/ssl/key.pem (renamed from test/http_SUITE_data/key.pem) | 0 | ||||
-rw-r--r-- | test/ws_SUITE.erl | 28 | ||||
-rw-r--r-- | test/ws_SUITE_data/ws_echo.erl (renamed from test/websocket_echo_handler.erl) | 2 | ||||
-rw-r--r-- | test/ws_SUITE_data/ws_echo_timer.erl (renamed from test/websocket_handler.erl) | 2 | ||||
-rw-r--r-- | test/ws_SUITE_data/ws_init_shutdown.erl (renamed from test/websocket_handler_init_shutdown.erl) | 2 | ||||
-rw-r--r-- | test/ws_SUITE_data/ws_send_many.erl (renamed from test/ws_send_many_handler.erl) | 2 | ||||
-rw-r--r-- | test/ws_SUITE_data/ws_timeout_cancel.erl (renamed from test/ws_timeout_cancel_handler.erl) | 2 | ||||
-rw-r--r-- | test/ws_SUITE_data/ws_timeout_hibernate.erl (renamed from test/ws_timeout_hibernate_handler.erl) | 2 | ||||
-rw-r--r-- | test/ws_SUITE_data/ws_upgrade_with_opts.erl (renamed from test/ws_upgrade_with_opts_handler.erl) | 2 |
41 files changed, 141 insertions, 71 deletions
@@ -21,7 +21,8 @@ erlc_verbose = $(erlc_verbose_$(V)) gen_verbose_0 = @echo " GEN " $@; gen_verbose = $(gen_verbose_$(V)) -.PHONY: all clean-all app clean deps clean-deps docs clean-docs tests autobahn build-plt dialyze +.PHONY: all clean-all app clean deps clean-deps docs clean-docs \ + build-tests tests autobahn build-plt dialyze # Application. @@ -71,7 +72,12 @@ clean-docs: # Tests. +build-tests: + $(gen_verbose) erlc -v $(ERLC_OPTS) \ + -o test/ test/*.erl test/*/*.erl -pa ebin/ + CT_RUN = ct_run \ + -no_auto_compile \ -noshell \ -pa ebin $(DEPS_DIR)/*/ebin \ -dir test \ @@ -79,11 +85,12 @@ CT_RUN = ct_run \ # -cover test/cover.spec tests: ERLC_OPTS += -DTEST=1 -tests: clean clean-deps deps app +tests: clean clean-deps deps app build-tests @mkdir -p logs/ @$(CT_RUN) -suite eunit_SUITE http_SUITE ws_SUITE + $(gen_verbose) rm -f test/*.beam -autobahn: clean clean-deps deps app +autobahn: clean clean-deps deps app build-tests @mkdir -p logs/ @$(CT_RUN) -suite autobahn_SUITE diff --git a/guide/rest_handlers.md b/guide/rest_handlers.md index d5997f9..ac11d98 100644 --- a/guide/rest_handlers.md +++ b/guide/rest_handlers.md @@ -106,6 +106,19 @@ each function. For example, `from_html` and `to_html` indicate in the first case that we're accepting a resource given as HTML, and in the second case that we send one as HTML. +Cowboy will set informative meta values at various points of the +execution. You can retrieve them using `cowboy_req:meta/{2,3}`. +The values are defined in the following table. + +| Meta key | Details | +| -----------| ---------------------------------------------------- | +| media_type | The content-type negotiated for the response entity. | +| language | The language negotiated for the response entity. | +| charset | The charset negotiated for the response entity. | + +They can be used to reply a response entity to a request with +an idempotent method (`POST`, `PUT`, `PATCH`, `DELETE`). + Usage ----- diff --git a/guide/static_handlers.md b/guide/static_handlers.md index 0843599..d6347f0 100644 --- a/guide/static_handlers.md +++ b/guide/static_handlers.md @@ -19,8 +19,7 @@ Static handlers are pre-written REST handlers. They only need to be specified in the routing information with the proper options. The following example routing serves all files found in the -`priv_dir/static/` directory of the application `my_app`. It uses -a mimetypes library to figure out the files' content types. +`priv_dir/static/` directory of the application `my_app`. ``` erlang Dispatch = [ @@ -32,3 +31,32 @@ Dispatch = [ ]} ]. ``` + +You can also serve a single file specifically. A common example +would be an `index.html` file to be served when the path `/` +is requested. The following example will serve the `priv/index.html` +file from the application `my_app`. + +``` erlang +Dispatch = [ + {'_', [ + {"/", cowboy_static, [ + {directory, {priv_dir, my_app, []}}, + {file, "index.html"}, + {mimetypes, {fun mimetypes:path_to_mimes/2, default}} + ]} + ]} +]. +``` + +MIME type +--------- + +Cowboy does not provide any default for MIME types. This means +that unless you specify the `mimetypes` option, all files will +be sent as `application/octet-stream`, which the browser will +not try to interpret, instead trying to make you download it. + +In the examples above we used the +[mimetypes application](https://github.com/spawngrid/mimetypes) +to find the MIME type from the file's extension. diff --git a/guide/toc.md b/guide/toc.md index 6909bed..44c8e22 100644 --- a/guide/toc.md +++ b/guide/toc.md @@ -34,6 +34,7 @@ Cowboy User Guide * [Static handlers](static_handlers.md) * Purpose * Usage + * MIME type * [Request object](req.md) * Purpose * Request diff --git a/src/cowboy_http.erl b/src/cowboy_http.erl index 57dac0b..b958020 100644 --- a/src/cowboy_http.erl +++ b/src/cowboy_http.erl @@ -157,8 +157,7 @@ cookie_name(Data = << C, _Rest/binary >>, Fun, Acc) C =:= $\r; C =:= $\n; C =:= $\013; C =:= $\014 -> Fun(Data, Acc); cookie_name(<< C, Rest/binary >>, Fun, Acc) -> - C2 = cowboy_bstr:char_to_lower(C), - cookie_name(Rest, Fun, << Acc/binary, C2 >>). + cookie_name(Rest, Fun, << Acc/binary, C >>). -spec cookie_value(binary(), fun()) -> any(). cookie_value(Data, Fun) -> @@ -1110,14 +1109,14 @@ cookie_list_test_() -> {<<"name2">>, <<"value2">>} ]}, {<<"$Version=1; Customer=WILE_E_COYOTE; $Path=/acme">>, [ - {<<"customer">>, <<"WILE_E_COYOTE">>} + {<<"Customer">>, <<"WILE_E_COYOTE">>} ]}, {<<"$Version=1; Customer=WILE_E_COYOTE; $Path=/acme; " "Part_Number=Rocket_Launcher_0001; $Path=/acme; " "Shipping=FedEx; $Path=/acme">>, [ - {<<"customer">>, <<"WILE_E_COYOTE">>}, - {<<"part_number">>, <<"Rocket_Launcher_0001">>}, - {<<"shipping">>, <<"FedEx">>} + {<<"Customer">>, <<"WILE_E_COYOTE">>}, + {<<"Part_Number">>, <<"Rocket_Launcher_0001">>}, + {<<"Shipping">>, <<"FedEx">>} ]}, %% Potential edge cases (initially from Mochiweb). {<<"foo=\\x">>, [{<<"foo">>, <<"\\x">>}]}, diff --git a/src/cowboy_req.erl b/src/cowboy_req.erl index 4ec42f9..11b0e26 100644 --- a/src/cowboy_req.erl +++ b/src/cowboy_req.erl @@ -29,8 +29,7 @@ %% </dl> %% %% Exceptions include <em>chunk/2</em> which always returns <em>'ok'</em>, -%% <em>to_list/1</em> which returns a list of key/values, -%% and <em>transport/1</em> which returns <em>{ok, Transport, Socket}</em>. +%% and <em>to_list/1</em> which returns a list of key/values. %% %% Also note that all body reading functions perform actions, as Cowboy %% doesn't read the request body until they are called. diff --git a/test/autobahn_SUITE.erl b/test/autobahn_SUITE.erl index 61cf631..68a9221 100644 --- a/test/autobahn_SUITE.erl +++ b/test/autobahn_SUITE.erl @@ -76,7 +76,7 @@ end_per_group(Listener, _Config) -> init_dispatch() -> cowboy_router:compile([{"localhost", [ - {"/echo", websocket_echo_handler, []}]}]). + {"/echo", autobahn_echo, []}]}]). %% autobahn cases diff --git a/test/autobahn_SUITE_data/autobahn_echo.erl b/test/autobahn_SUITE_data/autobahn_echo.erl new file mode 100644 index 0000000..07f7fd9 --- /dev/null +++ b/test/autobahn_SUITE_data/autobahn_echo.erl @@ -0,0 +1,26 @@ +%% Feel free to use, reuse and abuse the code in this file. + +-module(autobahn_echo). +-behaviour(cowboy_websocket_handler). +-export([init/3]). +-export([websocket_init/3, websocket_handle/3, + websocket_info/3, websocket_terminate/3]). + +init(_Any, _Req, _Opts) -> + {upgrade, protocol, cowboy_websocket}. + +websocket_init(_TransportName, Req, _Opts) -> + {ok, Req, undefined}. + +websocket_handle({text, Data}, Req, State) -> + {reply, {text, Data}, Req, State}; +websocket_handle({binary, Data}, Req, State) -> + {reply, {binary, Data}, Req, State}; +websocket_handle(_Frame, Req, State) -> + {ok, Req, State}. + +websocket_info(_Info, Req, State) -> + {ok, Req, State}. + +websocket_terminate(_Reason, _Req, _State) -> + ok. diff --git a/test/autobahn_SUITE_data/test.py b/test/autobahn_SUITE_data/test.py index 19c7669..f142683 100755 --- a/test/autobahn_SUITE_data/test.py +++ b/test/autobahn_SUITE_data/test.py @@ -29,7 +29,7 @@ def install_env(env): subprocess.check_call(["curl", "-sS", VIRTUALENV_URL, "-o", VIRTUALENV_BIN]) subprocess.check_call(["python", VIRTUALENV_BIN, env]) activate_env(env) - subprocess.check_call([INSTALL_BIN, "http://pypi.python.org/packages/2.7/a/autobahntestsuite/autobahntestsuite-0.5.2-py2.7.egg#md5=f7480d4ca6ce4954ac05f59778de4bda"]) + subprocess.check_call([INSTALL_BIN, "http://pypi.python.org/packages/2.7/a/autobahntestsuite/autobahntestsuite-0.5.3-py2.7.egg"]) def client_config(): """ @@ -39,13 +39,10 @@ def client_config(): 'options': {'failByDrop': False}, 'enable-ssl': False, 'servers': [{ - 'agent': 'Cowboy/10', + 'agent': 'Cowboy', 'url': 'ws://localhost:33080/echo', - 'options': {'version': 10}}, # hybi-10 - {'agent': 'Cowboy/18', - 'url': 'ws://localhost:33080/echo', - 'options': {'version': 18}} # RFC6455 - ], + 'options': {'version': 18} # RFC6455 + }], 'cases': ['*'], 'exclude-cases': [] } return base diff --git a/test/http_SUITE.erl b/test/http_SUITE.erl index c9a357e..168503c 100644 --- a/test/http_SUITE.erl +++ b/test/http_SUITE.erl @@ -206,8 +206,8 @@ init_per_group(http, Config) -> init_per_group(https, Config) -> Transport = ranch_ssl, Opts = [ - {certfile, ?config(data_dir, Config) ++ "cert.pem"}, - {keyfile, ?config(data_dir, Config) ++ "key.pem"}, + {certfile, ?config(data_dir, Config) ++ "ssl/cert.pem"}, + {keyfile, ?config(data_dir, Config) ++ "ssl/key.pem"}, {password, "cowboy"} ], Config1 = init_static_dir(Config), @@ -238,8 +238,8 @@ init_per_group(http_compress, Config) -> init_per_group(https_compress, Config) -> Transport = ranch_ssl, Opts = [ - {certfile, ?config(data_dir, Config) ++ "cert.pem"}, - {keyfile, ?config(data_dir, Config) ++ "key.pem"}, + {certfile, ?config(data_dir, Config) ++ "ssl/cert.pem"}, + {keyfile, ?config(data_dir, Config) ++ "ssl/key.pem"}, {password, "cowboy"} ], Config1 = init_static_dir(Config), @@ -321,21 +321,21 @@ end_per_group(Name, _) -> init_dispatch(Config) -> cowboy_router:compile([ {"localhost", [ - {"/chunked_response", chunked_handler, []}, - {"/init_shutdown", http_handler_init_shutdown, []}, - {"/long_polling", http_handler_long_polling, []}, + {"/chunked_response", http_chunked, []}, + {"/init_shutdown", http_init_shutdown, []}, + {"/long_polling", http_long_polling, []}, {"/headers/dupe", http_handler, [{headers, [{<<"connection">>, <<"close">>}]}]}, - {"/set_resp/header", http_handler_set_resp, + {"/set_resp/header", http_set_resp, [{headers, [{<<"vary">>, <<"Accept">>}]}]}, - {"/set_resp/overwrite", http_handler_set_resp, + {"/set_resp/overwrite", http_set_resp, [{headers, [{<<"server">>, <<"DesireDrive/1.0">>}]}]}, - {"/set_resp/body", http_handler_set_resp, + {"/set_resp/body", http_set_resp, [{body, <<"A flameless dance does not equal a cycle">>}]}, - {"/stream_body/set_resp", http_handler_stream_body, + {"/stream_body/set_resp", http_stream_body, [{reply, set_resp}, {body, <<"stream_body_set_resp">>}]}, {"/stream_body/set_resp_close", - http_handler_stream_body, [ + http_stream_body, [ {reply, set_resp_close}, {body, <<"stream_body_set_resp_close">>}]}, {"/static/[...]", cowboy_static, @@ -345,7 +345,7 @@ init_dispatch(Config) -> [{directory, ?config(static_dir, Config)}, {mimetypes, {fun(Path, data) when is_binary(Path) -> [<<"text/html">>] end, data}}]}, - {"/handler_errors", http_handler_errors, []}, + {"/handler_errors", http_errors, []}, {"/static_attribute_etag/[...]", cowboy_static, [{directory, ?config(static_dir, Config)}, {etag, {attributes, [filepath, filesize, inode, mtime]}}]}, @@ -356,9 +356,9 @@ init_dispatch(Config) -> [{directory, ?config(static_dir, Config)}, {mimetypes, [{<<".css">>, [<<"text/css">>]}]}, {file, <<"test_file.css">>}]}, - {"/multipart", http_handler_multipart, []}, - {"/echo/body", http_handler_echo_body, []}, - {"/echo/body_qs", http_handler_body_qs, []}, + {"/multipart", http_multipart, []}, + {"/echo/body", http_echo_body, []}, + {"/echo/body_qs", http_body_qs, []}, {"/param_all", rest_param_all, []}, {"/bad_accept", rest_simple_resource, []}, {"/bad_content_type", rest_patch_resource, []}, @@ -373,8 +373,8 @@ init_dispatch(Config) -> {"/resetags", rest_resource_etags, []}, {"/rest_expires", rest_expires, []}, {"/rest_empty_resource", rest_empty_resource, []}, - {"/loop_recv", http_handler_loop_recv, []}, - {"/loop_timeout", http_handler_loop_timeout, []}, + {"/loop_recv", http_loop_recv, []}, + {"/loop_timeout", http_loop_timeout, []}, {"/", http_handler, []} ]} ]). diff --git a/test/http_handler_body_qs.erl b/test/http_SUITE_data/http_body_qs.erl index 306f4dc..2280981 100644 --- a/test/http_handler_body_qs.erl +++ b/test/http_SUITE_data/http_body_qs.erl @@ -1,6 +1,6 @@ %% Feel free to use, reuse and abuse the code in this file. --module(http_handler_body_qs). +-module(http_body_qs). -behaviour(cowboy_http_handler). -export([init/3, handle/2, terminate/3]). diff --git a/test/chunked_handler.erl b/test/http_SUITE_data/http_chunked.erl index e486afe..447c0f6 100644 --- a/test/chunked_handler.erl +++ b/test/http_SUITE_data/http_chunked.erl @@ -1,6 +1,6 @@ %% Feel free to use, reuse and abuse the code in this file. --module(chunked_handler). +-module(http_chunked). -behaviour(cowboy_http_handler). -export([init/3, handle/2, terminate/3]). diff --git a/test/http_handler_echo_body.erl b/test/http_SUITE_data/http_echo_body.erl index 4b9e765..014e05a 100644 --- a/test/http_handler_echo_body.erl +++ b/test/http_SUITE_data/http_echo_body.erl @@ -1,6 +1,6 @@ %% Feel free to use, reuse and abuse the code in this file. --module(http_handler_echo_body). +-module(http_echo_body). -behaviour(cowboy_http_handler). -export([init/3, handle/2, terminate/3]). diff --git a/test/http_handler_errors.erl b/test/http_SUITE_data/http_errors.erl index 2d1066c..8831362 100644 --- a/test/http_handler_errors.erl +++ b/test/http_SUITE_data/http_errors.erl @@ -1,6 +1,6 @@ %% Feel free to use, reuse and abuse the code in this file. --module(http_handler_errors). +-module(http_errors). -behaviour(cowboy_http_handler). -export([init/3, handle/2, terminate/3]). diff --git a/test/http_handler.erl b/test/http_SUITE_data/http_handler.erl index e1f1665..e1f1665 100644 --- a/test/http_handler.erl +++ b/test/http_SUITE_data/http_handler.erl diff --git a/test/http_handler_init_shutdown.erl b/test/http_SUITE_data/http_init_shutdown.erl index fd01983..1445569 100644 --- a/test/http_handler_init_shutdown.erl +++ b/test/http_SUITE_data/http_init_shutdown.erl @@ -1,6 +1,6 @@ %% Feel free to use, reuse and abuse the code in this file. --module(http_handler_init_shutdown). +-module(http_init_shutdown). -behaviour(cowboy_http_handler). -export([init/3, handle/2, terminate/3]). diff --git a/test/http_handler_long_polling.erl b/test/http_SUITE_data/http_long_polling.erl index e8cf610..ad4e66e 100644 --- a/test/http_handler_long_polling.erl +++ b/test/http_SUITE_data/http_long_polling.erl @@ -1,6 +1,6 @@ %% Feel free to use, reuse and abuse the code in this file. --module(http_handler_long_polling). +-module(http_long_polling). -behaviour(cowboy_http_handler). -export([init/3, handle/2, info/3, terminate/3]). diff --git a/test/http_handler_loop_recv.erl b/test/http_SUITE_data/http_loop_recv.erl index 4d0a321..d0577f0 100644 --- a/test/http_handler_loop_recv.erl +++ b/test/http_SUITE_data/http_loop_recv.erl @@ -1,6 +1,6 @@ %% Feel free to use, reuse and abuse the code in this file. --module(http_handler_loop_recv). +-module(http_loop_recv). -behaviour(cowboy_loop_handler). -export([init/3, info/3, terminate/3]). diff --git a/test/http_handler_loop_timeout.erl b/test/http_SUITE_data/http_loop_timeout.erl index 0155b1e..dd3472c 100644 --- a/test/http_handler_loop_timeout.erl +++ b/test/http_SUITE_data/http_loop_timeout.erl @@ -1,6 +1,6 @@ %% Feel free to use, reuse and abuse the code in this file. --module(http_handler_loop_timeout). +-module(http_loop_timeout). -behaviour(cowboy_loop_handler). -export([init/3, info/3, terminate/3]). diff --git a/test/http_handler_multipart.erl b/test/http_SUITE_data/http_multipart.erl index 8209535..c94739f 100644 --- a/test/http_handler_multipart.erl +++ b/test/http_SUITE_data/http_multipart.erl @@ -1,6 +1,6 @@ %% Feel free to use, reuse and abuse the code in this file. --module(http_handler_multipart). +-module(http_multipart). -behaviour(cowboy_http_handler). -export([init/3, handle/2, terminate/3]). diff --git a/test/http_handler_set_resp.erl b/test/http_SUITE_data/http_set_resp.erl index d00d72a..821cc1d 100644 --- a/test/http_handler_set_resp.erl +++ b/test/http_SUITE_data/http_set_resp.erl @@ -1,6 +1,6 @@ %% Feel free to use, reuse and abuse the code in this file. --module(http_handler_set_resp). +-module(http_set_resp). -behaviour(cowboy_http_handler). -export([init/3, handle/2, terminate/3]). diff --git a/test/http_handler_stream_body.erl b/test/http_SUITE_data/http_stream_body.erl index 5e42fa7..4f45656 100644 --- a/test/http_handler_stream_body.erl +++ b/test/http_SUITE_data/http_stream_body.erl @@ -1,6 +1,6 @@ %% Feel free to use, reuse and abuse the code in this file. --module(http_handler_stream_body). +-module(http_stream_body). -behaviour(cowboy_http_handler). -export([init/3, handle/2, terminate/3]). diff --git a/test/rest_empty_resource.erl b/test/http_SUITE_data/rest_empty_resource.erl index 7e7c00a..7e7c00a 100644 --- a/test/rest_empty_resource.erl +++ b/test/http_SUITE_data/rest_empty_resource.erl diff --git a/test/rest_expires.erl b/test/http_SUITE_data/rest_expires.erl index 4209041..4209041 100644 --- a/test/rest_expires.erl +++ b/test/http_SUITE_data/rest_expires.erl diff --git a/test/rest_forbidden_resource.erl b/test/http_SUITE_data/rest_forbidden_resource.erl index 287ff62..287ff62 100644 --- a/test/rest_forbidden_resource.erl +++ b/test/http_SUITE_data/rest_forbidden_resource.erl diff --git a/test/rest_missing_callbacks.erl b/test/http_SUITE_data/rest_missing_callbacks.erl index 171c856..171c856 100644 --- a/test/rest_missing_callbacks.erl +++ b/test/http_SUITE_data/rest_missing_callbacks.erl diff --git a/test/rest_nodelete_resource.erl b/test/http_SUITE_data/rest_nodelete_resource.erl index 9f9670c..9f9670c 100644 --- a/test/rest_nodelete_resource.erl +++ b/test/http_SUITE_data/rest_nodelete_resource.erl diff --git a/test/rest_param_all.erl b/test/http_SUITE_data/rest_param_all.erl index 09b8cd3..09b8cd3 100644 --- a/test/rest_param_all.erl +++ b/test/http_SUITE_data/rest_param_all.erl diff --git a/test/rest_patch_resource.erl b/test/http_SUITE_data/rest_patch_resource.erl index e265f6f..e265f6f 100644 --- a/test/rest_patch_resource.erl +++ b/test/http_SUITE_data/rest_patch_resource.erl diff --git a/test/rest_resource_etags.erl b/test/http_SUITE_data/rest_resource_etags.erl index 43f1e05..43f1e05 100644 --- a/test/rest_resource_etags.erl +++ b/test/http_SUITE_data/rest_resource_etags.erl diff --git a/test/rest_simple_resource.erl b/test/http_SUITE_data/rest_simple_resource.erl index 97145dd..97145dd 100644 --- a/test/rest_simple_resource.erl +++ b/test/http_SUITE_data/rest_simple_resource.erl diff --git a/test/http_SUITE_data/cert.pem b/test/http_SUITE_data/ssl/cert.pem index a772007..a772007 100644 --- a/test/http_SUITE_data/cert.pem +++ b/test/http_SUITE_data/ssl/cert.pem diff --git a/test/http_SUITE_data/key.pem b/test/http_SUITE_data/ssl/key.pem index 0b699cc..0b699cc 100644 --- a/test/http_SUITE_data/key.pem +++ b/test/http_SUITE_data/ssl/key.pem diff --git a/test/ws_SUITE.erl b/test/ws_SUITE.erl index b6709ca..fbef41a 100644 --- a/test/ws_SUITE.erl +++ b/test/ws_SUITE.erl @@ -90,30 +90,30 @@ end_per_group(Listener, _Config) -> init_dispatch() -> cowboy_router:compile([ {"localhost", [ - {"/websocket", websocket_handler, []}, - {"/ws_echo_handler", websocket_echo_handler, []}, - {"/ws_init_shutdown", websocket_handler_init_shutdown, []}, - {"/ws_send_many", ws_send_many_handler, [ + {"/ws_echo_timer", ws_echo_timer, []}, + {"/ws_echo", ws_echo, []}, + {"/ws_init_shutdown", ws_init_shutdown, []}, + {"/ws_send_many", ws_send_many, [ {sequence, [ {text, <<"one">>}, {text, <<"two">>}, {text, <<"seven!">>}]} ]}, - {"/ws_send_close", ws_send_many_handler, [ + {"/ws_send_close", ws_send_many, [ {sequence, [ {text, <<"send">>}, close, {text, <<"won't be received">>}]} ]}, - {"/ws_send_close_payload", ws_send_many_handler, [ + {"/ws_send_close_payload", ws_send_many, [ {sequence, [ {text, <<"send">>}, {close, 1001, <<"some text!">>}, {text, <<"won't be received">>}]} ]}, - {"/ws_timeout_hibernate", ws_timeout_hibernate_handler, []}, - {"/ws_timeout_cancel", ws_timeout_cancel_handler, []}, - {"/ws_upgrade_with_opts", ws_upgrade_with_opts_handler, + {"/ws_timeout_hibernate", ws_timeout_hibernate, []}, + {"/ws_timeout_cancel", ws_timeout_cancel, []}, + {"/ws_upgrade_with_opts", ws_upgrade_with_opts, <<"failure">>} ]} ]). @@ -126,7 +126,7 @@ ws0(Config) -> {ok, Socket} = gen_tcp:connect("localhost", Port, [binary, {active, false}, {packet, raw}]), ok = gen_tcp:send(Socket, - "GET /websocket HTTP/1.1\r\n" + "GET /ws_echo_timer HTTP/1.1\r\n" "Host: localhost\r\n" "Connection: Upgrade\r\n" "Upgrade: WebSocket\r\n" @@ -143,7 +143,7 @@ ws8(Config) -> {ok, Socket} = gen_tcp:connect("localhost", Port, [binary, {active, false}, {packet, raw}]), ok = gen_tcp:send(Socket, [ - "GET /websocket HTTP/1.1\r\n" + "GET /ws_echo_timer HTTP/1.1\r\n" "Host: localhost\r\n" "Connection: Upgrade\r\n" "Upgrade: websocket\r\n" @@ -203,7 +203,7 @@ ws8_single_bytes(Config) -> {ok, Socket} = gen_tcp:connect("localhost", Port, [binary, {active, false}, {packet, raw}]), ok = gen_tcp:send(Socket, [ - "GET /websocket HTTP/1.1\r\n" + "GET /ws_echo_timer HTTP/1.1\r\n" "Host: localhost\r\n" "Connection: Upgrade\r\n" "Upgrade: websocket\r\n" @@ -263,7 +263,7 @@ ws13(Config) -> {ok, Socket} = gen_tcp:connect("localhost", Port, [binary, {active, false}, {packet, raw}]), ok = gen_tcp:send(Socket, [ - "GET /websocket HTTP/1.1\r\n" + "GET /ws_echo_timer HTTP/1.1\r\n" "Host: localhost\r\n" "Connection: Upgrade\r\n" "Origin: http://localhost\r\n" @@ -404,7 +404,7 @@ ws_text_fragments(Config) -> {ok, Socket} = gen_tcp:connect("localhost", Port, [binary, {active, false}, {packet, raw}]), ok = gen_tcp:send(Socket, [ - "GET /ws_echo_handler HTTP/1.1\r\n" + "GET /ws_echo HTTP/1.1\r\n" "Host: localhost\r\n" "Connection: Upgrade\r\n" "Upgrade: websocket\r\n" diff --git a/test/websocket_echo_handler.erl b/test/ws_SUITE_data/ws_echo.erl index 21b0116..d4a5f07 100644 --- a/test/websocket_echo_handler.erl +++ b/test/ws_SUITE_data/ws_echo.erl @@ -1,6 +1,6 @@ %% Feel free to use, reuse and abuse the code in this file. --module(websocket_echo_handler). +-module(ws_echo). -behaviour(cowboy_websocket_handler). -export([init/3]). -export([websocket_init/3, websocket_handle/3, diff --git a/test/websocket_handler.erl b/test/ws_SUITE_data/ws_echo_timer.erl index a9863ae..666a26d 100644 --- a/test/websocket_handler.erl +++ b/test/ws_SUITE_data/ws_echo_timer.erl @@ -1,6 +1,6 @@ %% Feel free to use, reuse and abuse the code in this file. --module(websocket_handler). +-module(ws_echo_timer). -behaviour(cowboy_websocket_handler). -export([init/3]). -export([websocket_init/3, websocket_handle/3, diff --git a/test/websocket_handler_init_shutdown.erl b/test/ws_SUITE_data/ws_init_shutdown.erl index 7ccea05..2b1dd99 100644 --- a/test/websocket_handler_init_shutdown.erl +++ b/test/ws_SUITE_data/ws_init_shutdown.erl @@ -1,6 +1,6 @@ %% Feel free to use, reuse and abuse the code in this file. --module(websocket_handler_init_shutdown). +-module(ws_init_shutdown). -behaviour(cowboy_websocket_handler). -export([init/3]). -export([websocket_init/3, websocket_handle/3, diff --git a/test/ws_send_many_handler.erl b/test/ws_SUITE_data/ws_send_many.erl index bd67814..2ed4772 100644 --- a/test/ws_send_many_handler.erl +++ b/test/ws_SUITE_data/ws_send_many.erl @@ -1,6 +1,6 @@ %% Feel free to use, reuse and abuse the code in this file. --module(ws_send_many_handler). +-module(ws_send_many). -behaviour(cowboy_websocket_handler). -export([init/3]). diff --git a/test/ws_timeout_cancel_handler.erl b/test/ws_SUITE_data/ws_timeout_cancel.erl index 68b0468..9c7b72b 100644 --- a/test/ws_timeout_cancel_handler.erl +++ b/test/ws_SUITE_data/ws_timeout_cancel.erl @@ -1,6 +1,6 @@ %% Feel free to use, reuse and abuse the code in this file. --module(ws_timeout_cancel_handler). +-module(ws_timeout_cancel). -behaviour(cowboy_websocket_handler). -export([init/3]). -export([websocket_init/3, websocket_handle/3, diff --git a/test/ws_timeout_hibernate_handler.erl b/test/ws_SUITE_data/ws_timeout_hibernate.erl index 41b9edd..cc91e26 100644 --- a/test/ws_timeout_hibernate_handler.erl +++ b/test/ws_SUITE_data/ws_timeout_hibernate.erl @@ -1,6 +1,6 @@ %% Feel free to use, reuse and abuse the code in this file. --module(ws_timeout_hibernate_handler). +-module(ws_timeout_hibernate). -behaviour(cowboy_websocket_handler). -export([init/3]). -export([websocket_init/3, websocket_handle/3, diff --git a/test/ws_upgrade_with_opts_handler.erl b/test/ws_SUITE_data/ws_upgrade_with_opts.erl index 02d755e..b4f82fa 100644 --- a/test/ws_upgrade_with_opts_handler.erl +++ b/test/ws_SUITE_data/ws_upgrade_with_opts.erl @@ -1,6 +1,6 @@ %% Feel free to use, reuse and abuse the code in this file. --module(ws_upgrade_with_opts_handler). +-module(ws_upgrade_with_opts). -behaviour(cowboy_websocket_handler). -export([init/3]). |