Commits

Oscar Hellström  committed 78aee79

Add test for 304 "Not Modified"

  • Participants
  • Parent commits d7b3aa3
  • Branches 1.2

Comments (0)

Files changed (1)

File test/lhttpc_tests.erl

                 ?_test(get_with_mandatory_hdrs()),
                 ?_test(no_content_length()),
                 ?_test(no_content_length_1_0()),
+                ?_test(get_not_modified()),
                 ?_test(simple_head()),
                 ?_test(simple_head_atom()),
                 ?_test(delete_no_content()),
     ?assertEqual({200, "OK"}, status(Response)),
     ?assertEqual(<<?DEFAULT_STRING>>, body(Response)).
 
+get_not_modified() ->
+    Port = start(gen_tcp, [fun not_modified_response/5]),
+    URL = url(Port, "/not_modified"),
+    {ok, Response} = lhttpc:request(URL, "GET", [], [], 1000),
+    ?assertEqual({304, "Not Modified"}, status(Response)),
+    ?assertEqual(<<>>, body(Response)).
+
 simple_head() ->
     Port = start(gen_tcp, [fun head_response/5]),
     URL = url(Port, "/HEAD"),
         "Content-type: text/plain\r\nContent-length: 14\r\n\r\n"
     ),
     Module:close(Socket).
+
+not_modified_response(Module, Socket, _Request, _Headers, _Body) ->
+    Module:send(
+        Socket,
+		[
+			"HTTP/1.1 304 Not Modified\r\n"
+			"Date: Tue, 15 Nov 1994 08:12:31 GMT\r\n\r\n"
+		]
+    ).