http_SUITE.erl 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417
  1. %% Copyright (c) 2011, Loïc Hoguin <essen@dev-extend.eu>
  2. %%
  3. %% Permission to use, copy, modify, and/or distribute this software for any
  4. %% purpose with or without fee is hereby granted, provided that the above
  5. %% copyright notice and this permission notice appear in all copies.
  6. %%
  7. %% THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  8. %% WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  9. %% MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  10. %% ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  11. %% WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  12. %% ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  13. %% OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  14. -module(http_SUITE).
  15. -include_lib("common_test/include/ct.hrl").
  16. -export([all/0, groups/0, init_per_suite/1, end_per_suite/1,
  17. init_per_group/2, end_per_group/2]). %% ct.
  18. -export([chunked_response/1, headers_dupe/1, headers_huge/1,
  19. keepalive_nl/1, nc_rand/1, pipeline/1, raw/1,
  20. ws0/1, ws8/1, ws8_single_bytes/1,
  21. ws_timeout_hibernate/1]). %% http.
  22. -export([http_200/1, http_404/1]). %% http and https.
  23. -export([http_10_hostless/1]). %% misc.
  24. %% ct.
  25. all() ->
  26. [{group, http}, {group, https}, {group, misc}].
  27. groups() ->
  28. BaseTests = [http_200, http_404],
  29. [{http, [], [chunked_response, headers_dupe, headers_huge,
  30. keepalive_nl, nc_rand, pipeline, raw,
  31. ws0, ws8, ws8_single_bytes,
  32. ws_timeout_hibernate] ++ BaseTests},
  33. {https, [], BaseTests}, {misc, [], [http_10_hostless]}].
  34. init_per_suite(Config) ->
  35. application:start(inets),
  36. application:start(cowboy),
  37. Config.
  38. end_per_suite(_Config) ->
  39. application:stop(cowboy),
  40. application:stop(inets),
  41. ok.
  42. init_per_group(http, Config) ->
  43. Port = 33080,
  44. cowboy:start_listener(http, 100,
  45. cowboy_tcp_transport, [{port, Port}],
  46. cowboy_http_protocol, [{dispatch, init_http_dispatch()}]
  47. ),
  48. [{scheme, "http"}, {port, Port}|Config];
  49. init_per_group(https, Config) ->
  50. Port = 33081,
  51. application:start(crypto),
  52. application:start(public_key),
  53. application:start(ssl),
  54. DataDir = ?config(data_dir, Config),
  55. cowboy:start_listener(https, 100,
  56. cowboy_ssl_transport, [
  57. {port, Port}, {certfile, DataDir ++ "cert.pem"},
  58. {keyfile, DataDir ++ "key.pem"}, {password, "cowboy"}],
  59. cowboy_http_protocol, [{dispatch, init_https_dispatch()}]
  60. ),
  61. [{scheme, "https"}, {port, Port}|Config];
  62. init_per_group(misc, Config) ->
  63. Port = 33082,
  64. cowboy:start_listener(misc, 100,
  65. cowboy_tcp_transport, [{port, Port}],
  66. cowboy_http_protocol, [{dispatch, [{'_', [
  67. {[], http_handler, []}
  68. ]}]}]),
  69. [{port, Port}|Config].
  70. end_per_group(https, _Config) ->
  71. cowboy:stop_listener(https),
  72. application:stop(ssl),
  73. application:stop(public_key),
  74. application:stop(crypto),
  75. ok;
  76. end_per_group(Listener, _Config) ->
  77. cowboy:stop_listener(Listener),
  78. ok.
  79. %% Dispatch configuration.
  80. init_http_dispatch() ->
  81. [
  82. {[<<"localhost">>], [
  83. {[<<"chunked_response">>], chunked_handler, []},
  84. {[<<"websocket">>], websocket_handler, []},
  85. {[<<"ws_timeout_hibernate">>], ws_timeout_hibernate_handler, []},
  86. {[<<"headers">>, <<"dupe">>], http_handler,
  87. [{headers, [{<<"Connection">>, <<"close">>}]}]},
  88. {[], http_handler, []}
  89. ]}
  90. ].
  91. init_https_dispatch() ->
  92. init_http_dispatch().
  93. %% http.
  94. chunked_response(Config) ->
  95. {ok, {{"HTTP/1.1", 200, "OK"}, _Headers, "chunked_handler\r\nworks fine!"}} =
  96. httpc:request(build_url("/chunked_response", Config)).
  97. headers_dupe(Config) ->
  98. {port, Port} = lists:keyfind(port, 1, Config),
  99. {ok, Socket} = gen_tcp:connect("localhost", Port,
  100. [binary, {active, false}, {packet, raw}]),
  101. ok = gen_tcp:send(Socket, "GET /headers/dupe HTTP/1.1\r\n"
  102. "Host: localhost\r\nConnection: keep-alive\r\n\r\n"),
  103. {ok, Data} = gen_tcp:recv(Socket, 0, 6000),
  104. {_Start, _Length} = binary:match(Data, <<"Connection: close">>),
  105. nomatch = binary:match(Data, <<"Connection: keep-alive">>),
  106. ok = gen_tcp:close(Socket).
  107. headers_huge(Config) ->
  108. Cookie = lists:flatten(["whatever_man_biiiiiiiiiiiig_cookie_me_want_77="
  109. "Wed Apr 06 2011 10:38:52 GMT-0500 (CDT)" || _N <- lists:seq(1, 1000)]),
  110. {_Packet, 200} = raw_req(["GET / HTTP/1.0\r\nHost: localhost\r\n"
  111. "Set-Cookie: ", Cookie, "\r\n\r\n"], Config).
  112. keepalive_nl(Config) ->
  113. {port, Port} = lists:keyfind(port, 1, Config),
  114. {ok, Socket} = gen_tcp:connect("localhost", Port,
  115. [binary, {active, false}, {packet, raw}]),
  116. ok = keepalive_nl_loop(Socket, 100),
  117. ok = gen_tcp:close(Socket).
  118. keepalive_nl_loop(_Socket, 0) ->
  119. ok;
  120. keepalive_nl_loop(Socket, N) ->
  121. ok = gen_tcp:send(Socket, "GET / HTTP/1.1\r\n"
  122. "Host: localhost\r\nConnection: keep-alive\r\n\r\n"),
  123. {ok, Data} = gen_tcp:recv(Socket, 0, 6000),
  124. {0, 12} = binary:match(Data, <<"HTTP/1.1 200">>),
  125. nomatch = binary:match(Data, <<"Connection: close">>),
  126. ok = gen_tcp:send(Socket, "\r\n"), %% extra nl
  127. keepalive_nl_loop(Socket, N - 1).
  128. nc_rand(Config) ->
  129. Cat = os:find_executable("cat"),
  130. Nc = os:find_executable("nc"),
  131. case {Cat, Nc} of
  132. {false, _} ->
  133. {skip, {notfound, cat}};
  134. {_, false} ->
  135. {skip, {notfound, nc}};
  136. _Good ->
  137. %% Throw garbage at the server then check if it's still up.
  138. {port, Port} = lists:keyfind(port, 1, Config),
  139. [nc_rand_run(Port) || _N <- lists:seq(1, 100)],
  140. Packet = "GET / HTTP/1.0\r\nHost: localhost\r\n\r\n",
  141. {Packet, 200} = raw_req(Packet, Config)
  142. end.
  143. nc_rand_run(Port) ->
  144. os:cmd("cat /dev/urandom | nc localhost " ++ integer_to_list(Port)).
  145. pipeline(Config) ->
  146. {port, Port} = lists:keyfind(port, 1, Config),
  147. {ok, Socket} = gen_tcp:connect("localhost", Port,
  148. [binary, {active, false}, {packet, raw}]),
  149. ok = gen_tcp:send(Socket,
  150. "GET / HTTP/1.1\r\nHost: localhost\r\nConnection: keep-alive\r\n\r\n"
  151. "GET / HTTP/1.1\r\nHost: localhost\r\nConnection: keep-alive\r\n\r\n"
  152. "GET / HTTP/1.1\r\nHost: localhost\r\nConnection: keep-alive\r\n\r\n"
  153. "GET / HTTP/1.1\r\nHost: localhost\r\nConnection: keep-alive\r\n\r\n"
  154. "GET / HTTP/1.1\r\nHost: localhost\r\nConnection: close\r\n\r\n"),
  155. Data = pipeline_recv(Socket, <<>>),
  156. Reqs = binary:split(Data, << "\r\n\r\nhttp_handler" >>, [global, trim]),
  157. 5 = length(Reqs),
  158. pipeline_check(Reqs).
  159. pipeline_check([]) ->
  160. ok;
  161. pipeline_check([Req|Tail]) ->
  162. << "HTTP/1.1 200", _Rest/bits >> = Req,
  163. pipeline_check(Tail).
  164. pipeline_recv(Socket, SoFar) ->
  165. case gen_tcp:recv(Socket, 0, 6000) of
  166. {ok, Data} ->
  167. pipeline_recv(Socket, << SoFar/binary, Data/binary >>);
  168. {error, closed} ->
  169. ok = gen_tcp:close(Socket),
  170. SoFar
  171. end.
  172. raw_req(Packet, Config) ->
  173. {port, Port} = lists:keyfind(port, 1, Config),
  174. {ok, Socket} = gen_tcp:connect("localhost", Port,
  175. [binary, {active, false}, {packet, raw}]),
  176. ok = gen_tcp:send(Socket, Packet),
  177. {ok, << "HTTP/1.1 ", Str:24/bits, _Rest/bits >>}
  178. = gen_tcp:recv(Socket, 0, 6000),
  179. gen_tcp:close(Socket),
  180. {Packet, list_to_integer(binary_to_list(Str))}.
  181. raw(Config) ->
  182. Tests = [
  183. {"\r\n\r\n\r\n\r\n\r\nGET / HTTP/1.1\r\nHost: localhost\r\n\r\n", 200},
  184. {"\n", 400},
  185. {"Garbage\r\n\r\n", 400},
  186. {"\r\n\r\n\r\n\r\n\r\n\r\n", 400},
  187. {"GET / HTTP/1.1\r\nHost: dev-extend.eu\r\n\r\n", 400},
  188. {"", 408},
  189. {"\r\n", 408},
  190. {"\r\n\r\n", 408},
  191. {"GET / HTTP/1.1", 408},
  192. {"GET / HTTP/1.1\r\n", 408},
  193. {"GET / HTTP/1.1\r\nHost: localhost", 408},
  194. {"GET / HTTP/1.1\r\nHost: localhost\r\n", 408},
  195. {"GET / HTTP/1.1\r\nHost: localhost\r\n\r", 408},
  196. {"GET http://localhost/ HTTP/1.1\r\n\r\n", 501},
  197. {"GET / HTTP/1.2\r\nHost: localhost\r\n\r\n", 505}
  198. ],
  199. [{Packet, StatusCode} = raw_req(Packet, Config)
  200. || {Packet, StatusCode} <- Tests].
  201. ws0(Config) ->
  202. {port, Port} = lists:keyfind(port, 1, Config),
  203. {ok, Socket} = gen_tcp:connect("localhost", Port,
  204. [binary, {active, false}, {packet, raw}]),
  205. ok = gen_tcp:send(Socket, [
  206. "GET /websocket HTTP/1.1\r\n"
  207. "Host: localhost\r\n"
  208. "Connection: Upgrade\r\n"
  209. "Upgrade: WebSocket\r\n"
  210. "Origin: http://localhost\r\n"
  211. "Sec-Websocket-Key1: Y\" 4 1Lj!957b8@0H756!i\r\n"
  212. "Sec-Websocket-Key2: 1711 M;4\\74 80<6\r\n"
  213. "\r\n", <<15,245,8,18,2,204,133,33>>]),
  214. {ok, Handshake} = gen_tcp:recv(Socket, 0, 6000),
  215. {ok, {http_response, {1, 1}, 101, "WebSocket Protocol Handshake"}, Rest}
  216. = erlang:decode_packet(http, Handshake, []),
  217. [Headers, Body] = websocket_headers(
  218. erlang:decode_packet(httph, Rest, []), []),
  219. {'Connection', "Upgrade"} = lists:keyfind('Connection', 1, Headers),
  220. {'Upgrade', "WebSocket"} = lists:keyfind('Upgrade', 1, Headers),
  221. {"sec-websocket-location", "ws://localhost/websocket"}
  222. = lists:keyfind("sec-websocket-location", 1, Headers),
  223. {"sec-websocket-origin", "http://localhost"}
  224. = lists:keyfind("sec-websocket-origin", 1, Headers),
  225. <<169,244,191,103,146,33,149,59,74,104,67,5,99,118,171,236>> = Body,
  226. ok = gen_tcp:send(Socket, << 0, "client_msg", 255 >>),
  227. {ok, << 0, "client_msg", 255 >>} = gen_tcp:recv(Socket, 0, 6000),
  228. {ok, << 0, "websocket_init", 255 >>} = gen_tcp:recv(Socket, 0, 6000),
  229. {ok, << 0, "websocket_handle", 255 >>} = gen_tcp:recv(Socket, 0, 6000),
  230. {ok, << 0, "websocket_handle", 255 >>} = gen_tcp:recv(Socket, 0, 6000),
  231. {ok, << 0, "websocket_handle", 255 >>} = gen_tcp:recv(Socket, 0, 6000),
  232. ok = gen_tcp:send(Socket, << 255, 0 >>),
  233. {ok, << 255, 0 >>} = gen_tcp:recv(Socket, 0, 6000),
  234. {error, closed} = gen_tcp:recv(Socket, 0, 6000),
  235. ok.
  236. ws8(Config) ->
  237. {port, Port} = lists:keyfind(port, 1, Config),
  238. {ok, Socket} = gen_tcp:connect("localhost", Port,
  239. [binary, {active, false}, {packet, raw}]),
  240. ok = gen_tcp:send(Socket, [
  241. "GET /websocket HTTP/1.1\r\n"
  242. "Host: localhost\r\n"
  243. "Connection: Upgrade\r\n"
  244. "Upgrade: websocket\r\n"
  245. "Sec-WebSocket-Origin: http://localhost\r\n"
  246. "Sec-WebSocket-Version: 8\r\n"
  247. "Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==\r\n"
  248. "\r\n"]),
  249. {ok, Handshake} = gen_tcp:recv(Socket, 0, 6000),
  250. {ok, {http_response, {1, 1}, 101, "Switching Protocols"}, Rest}
  251. = erlang:decode_packet(http, Handshake, []),
  252. [Headers, <<>>] = websocket_headers(
  253. erlang:decode_packet(httph, Rest, []), []),
  254. {'Connection', "Upgrade"} = lists:keyfind('Connection', 1, Headers),
  255. {'Upgrade', "websocket"} = lists:keyfind('Upgrade', 1, Headers),
  256. {"sec-websocket-accept", "s3pPLMBiTxaQ9kYGzzhZRbK+xOo="}
  257. = lists:keyfind("sec-websocket-accept", 1, Headers),
  258. ok = gen_tcp:send(Socket, << 16#81, 16#85, 16#37, 16#fa, 16#21, 16#3d,
  259. 16#7f, 16#9f, 16#4d, 16#51, 16#58 >>),
  260. {ok, << 1:1, 0:3, 1:4, 0:1, 5:7, "Hello" >>}
  261. = gen_tcp:recv(Socket, 0, 6000),
  262. {ok, << 1:1, 0:3, 1:4, 0:1, 14:7, "websocket_init" >>}
  263. = gen_tcp:recv(Socket, 0, 6000),
  264. {ok, << 1:1, 0:3, 1:4, 0:1, 16:7, "websocket_handle" >>}
  265. = gen_tcp:recv(Socket, 0, 6000),
  266. {ok, << 1:1, 0:3, 1:4, 0:1, 16:7, "websocket_handle" >>}
  267. = gen_tcp:recv(Socket, 0, 6000),
  268. {ok, << 1:1, 0:3, 1:4, 0:1, 16:7, "websocket_handle" >>}
  269. = gen_tcp:recv(Socket, 0, 6000),
  270. ok = gen_tcp:send(Socket, << 1:1, 0:3, 9:4, 0:8 >>), %% ping
  271. {ok, << 1:1, 0:3, 10:4, 0:8 >>} = gen_tcp:recv(Socket, 0, 6000), %% pong
  272. ok = gen_tcp:send(Socket, << 1:1, 0:3, 8:4, 0:8 >>), %% close
  273. {ok, << 1:1, 0:3, 8:4, 0:8 >>} = gen_tcp:recv(Socket, 0, 6000),
  274. {error, closed} = gen_tcp:recv(Socket, 0, 6000),
  275. ok.
  276. ws8_single_bytes(Config) ->
  277. {port, Port} = lists:keyfind(port, 1, Config),
  278. {ok, Socket} = gen_tcp:connect("localhost", Port,
  279. [binary, {active, false}, {packet, raw}]),
  280. ok = gen_tcp:send(Socket, [
  281. "GET /websocket HTTP/1.1\r\n"
  282. "Host: localhost\r\n"
  283. "Connection: Upgrade\r\n"
  284. "Upgrade: websocket\r\n"
  285. "Sec-WebSocket-Origin: http://localhost\r\n"
  286. "Sec-WebSocket-Version: 8\r\n"
  287. "Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==\r\n"
  288. "\r\n"]),
  289. {ok, Handshake} = gen_tcp:recv(Socket, 0, 6000),
  290. {ok, {http_response, {1, 1}, 101, "Switching Protocols"}, Rest}
  291. = erlang:decode_packet(http, Handshake, []),
  292. [Headers, <<>>] = websocket_headers(
  293. erlang:decode_packet(httph, Rest, []), []),
  294. {'Connection', "Upgrade"} = lists:keyfind('Connection', 1, Headers),
  295. {'Upgrade', "websocket"} = lists:keyfind('Upgrade', 1, Headers),
  296. {"sec-websocket-accept", "s3pPLMBiTxaQ9kYGzzhZRbK+xOo="}
  297. = lists:keyfind("sec-websocket-accept", 1, Headers),
  298. ok = gen_tcp:send(Socket, << 16#81 >>), %% send one byte
  299. ok = timer:sleep(100), %% sleep for a period
  300. ok = gen_tcp:send(Socket, << 16#85 >>), %% send another and so on
  301. ok = timer:sleep(100),
  302. ok = gen_tcp:send(Socket, << 16#37 >>),
  303. ok = timer:sleep(100),
  304. ok = gen_tcp:send(Socket, << 16#fa >>),
  305. ok = timer:sleep(100),
  306. ok = gen_tcp:send(Socket, << 16#21 >>),
  307. ok = timer:sleep(100),
  308. ok = gen_tcp:send(Socket, << 16#3d >>),
  309. ok = timer:sleep(100),
  310. ok = gen_tcp:send(Socket, << 16#7f >>),
  311. ok = timer:sleep(100),
  312. ok = gen_tcp:send(Socket, << 16#9f >>),
  313. ok = timer:sleep(100),
  314. ok = gen_tcp:send(Socket, << 16#4d >>),
  315. ok = timer:sleep(100),
  316. ok = gen_tcp:send(Socket, << 16#51 >>),
  317. ok = timer:sleep(100),
  318. ok = gen_tcp:send(Socket, << 16#58 >>),
  319. {ok, << 1:1, 0:3, 1:4, 0:1, 14:7, "websocket_init" >>}
  320. = gen_tcp:recv(Socket, 0, 6000),
  321. {ok, << 1:1, 0:3, 1:4, 0:1, 5:7, "Hello" >>}
  322. = gen_tcp:recv(Socket, 0, 6000),
  323. {ok, << 1:1, 0:3, 1:4, 0:1, 16:7, "websocket_handle" >>}
  324. = gen_tcp:recv(Socket, 0, 6000),
  325. {ok, << 1:1, 0:3, 1:4, 0:1, 16:7, "websocket_handle" >>}
  326. = gen_tcp:recv(Socket, 0, 6000),
  327. {ok, << 1:1, 0:3, 1:4, 0:1, 16:7, "websocket_handle" >>}
  328. = gen_tcp:recv(Socket, 0, 6000),
  329. ok = gen_tcp:send(Socket, << 1:1, 0:3, 9:4, 0:8 >>), %% ping
  330. {ok, << 1:1, 0:3, 10:4, 0:8 >>} = gen_tcp:recv(Socket, 0, 6000), %% pong
  331. ok = gen_tcp:send(Socket, << 1:1, 0:3, 8:4, 0:8 >>), %% close
  332. {ok, << 1:1, 0:3, 8:4, 0:8 >>} = gen_tcp:recv(Socket, 0, 6000),
  333. {error, closed} = gen_tcp:recv(Socket, 0, 6000),
  334. ok.
  335. ws_timeout_hibernate(Config) ->
  336. {port, Port} = lists:keyfind(port, 1, Config),
  337. {ok, Socket} = gen_tcp:connect("localhost", Port,
  338. [binary, {active, false}, {packet, raw}]),
  339. ok = gen_tcp:send(Socket, [
  340. "GET /ws_timeout_hibernate HTTP/1.1\r\n"
  341. "Host: localhost\r\n"
  342. "Connection: Upgrade\r\n"
  343. "Upgrade: websocket\r\n"
  344. "Sec-WebSocket-Origin: http://localhost\r\n"
  345. "Sec-WebSocket-Version: 8\r\n"
  346. "Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==\r\n"
  347. "\r\n"]),
  348. {ok, Handshake} = gen_tcp:recv(Socket, 0, 6000),
  349. {ok, {http_response, {1, 1}, 101, "Switching Protocols"}, Rest}
  350. = erlang:decode_packet(http, Handshake, []),
  351. [Headers, <<>>] = websocket_headers(
  352. erlang:decode_packet(httph, Rest, []), []),
  353. {'Connection', "Upgrade"} = lists:keyfind('Connection', 1, Headers),
  354. {'Upgrade', "websocket"} = lists:keyfind('Upgrade', 1, Headers),
  355. {"sec-websocket-accept", "s3pPLMBiTxaQ9kYGzzhZRbK+xOo="}
  356. = lists:keyfind("sec-websocket-accept", 1, Headers),
  357. {ok, << 1:1, 0:3, 8:4, 0:8 >>} = gen_tcp:recv(Socket, 0, 6000),
  358. {error, closed} = gen_tcp:recv(Socket, 0, 6000),
  359. ok.
  360. websocket_headers({ok, http_eoh, Rest}, Acc) ->
  361. [Acc, Rest];
  362. websocket_headers({ok, {http_header, _I, Key, _R, Value}, Rest}, Acc) ->
  363. F = fun(S) when is_atom(S) -> S; (S) -> string:to_lower(S) end,
  364. websocket_headers(erlang:decode_packet(httph, Rest, []),
  365. [{F(Key), Value}|Acc]).
  366. %% http and https.
  367. build_url(Path, Config) ->
  368. {scheme, Scheme} = lists:keyfind(scheme, 1, Config),
  369. {port, Port} = lists:keyfind(port, 1, Config),
  370. Scheme ++ "://localhost:" ++ integer_to_list(Port) ++ Path.
  371. http_200(Config) ->
  372. {ok, {{"HTTP/1.1", 200, "OK"}, _Headers, "http_handler"}} =
  373. httpc:request(build_url("/", Config)).
  374. http_404(Config) ->
  375. {ok, {{"HTTP/1.1", 404, "Not Found"}, _Headers, _Body}} =
  376. httpc:request(build_url("/not/found", Config)).
  377. %% misc.
  378. http_10_hostless(Config) ->
  379. Packet = "GET / HTTP/1.0\r\n\r\n",
  380. {Packet, 200} = raw_req(Packet, Config).