Commits

Anonymous committed 30c67a5

Add test for reading a body without content length from a HTTP/1.0 server

  • Participants
  • Parent commits 24eab6d

Comments (0)

Files changed (1)

File test/lhttpc_tests.erl

             ?_test(simple_get()),
             ?_test(empty_get()),
             ?_test(get_with_mandatory_hdrs()),
-            ?_test(no_content_length_get()),
+            ?_test(no_content_length()),
+            ?_test(no_content_length_1_0()),
             ?_test(server_connection_close()),
             ?_test(client_connection_close()),
             ?_test(pre_1_1_server_connection()),
     ?assertEqual({200, "OK"}, status(Response)),
     ?assertEqual(<<?DEFAULT_STRING>>, body(Response)).
 
-no_content_length_get() ->
+no_content_length() ->
     Port = start(gen_tcp, [fun no_content_length/5]),
     URL = url(Port, "/no_cl"),
     {ok, Response} = lhttpc:request(URL, "GET", [], 1000),
     ?assertEqual({200, "OK"}, status(Response)),
     ?assertEqual(<<?DEFAULT_STRING>>, body(Response)).
 
+no_content_length_1_0() ->
+    Port = start(gen_tcp, [fun no_content_length_1_0/5]),
+    URL = url(Port, "/no_cl"),
+    {ok, Response} = lhttpc:request(URL, "GET", [], 1000),
+    ?assertEqual({200, "OK"}, status(Response)),
+    ?assertEqual(<<?DEFAULT_STRING>>, body(Response)).
+
 server_connection_close() ->
     Port = start(gen_tcp, [fun respond_and_close/5]),
     URL = url(Port, "/close"),
         ?DEFAULT_STRING
     ).
 
+no_content_length_1_0(Module, Socket, _, _, _) ->
+    Module:send(
+        Socket,
+        "HTTP/1.0 200 OK\r\n"
+        "Content-type: text/plain\r\n\r\n"
+        ?DEFAULT_STRING
+    ).
+
 chunked_response(Module, Socket, _, _, _) ->
     Module:send(
         Socket,