@@ -208,6 +208,12 @@ end # @testset
208208 close(http. stream)
209209 return
210210 end
211+ if http. message. method == " POST" && http. message. target == " /post"
212+ read(http, String)
213+ HTTP. setstatus(http, 200 )
214+ HTTP. startwrite(http)
215+ return
216+ end
211217 HTTP. setstatus(http, 200 )
212218 HTTP. setheader(http, " Content-Type" => " text/plain" )
213219 msg = " hello, world"
@@ -270,19 +276,21 @@ end # @testset
270276 @test occursin(r" ^127.0.0.1 - - \[ (\d {2})/.*/(\d {4}):\d {2}:\d {2}:\d {2}.*\] \" HEAD / HTTP/1.1\" 200 0 \" -\" \" HTTP\. jl/.*\" $" , logs[4 ]. message)
271277
272278 # Custom log format
273- fmt = logfmt" $http_accept $sent_http_content_type $request $request_method $request_uri $remote_addr $remote_port $remote_user $server_protocol $time_iso8601 $time_local $status $body_bytes_sent "
279+ fmt = logfmt" $http_accept $sent_http_content_type $request $request_method $request_uri $remote_addr $remote_port $remote_user $server_protocol $time_iso8601 $time_local $status $body_bytes_sent $body_bytes_received "
274280 logs = with_testserver(fmt) do
275281 HTTP. get(" http://localhost:32612" , [" Accept" => " application/json" ])
276282 HTTP. get(" http://localhost:32612/index.html" )
277283 HTTP. get(" http://localhost:32612/index.html?a=b" )
278284 HTTP. head(" http://localhost:32612" )
285+ HTTP. post(" http://localhost:32612/post" , [], " hello, world" )
279286 end
280- @test length(logs) == 4
287+ @test length(logs) == 5
281288 @test all(x -> x. group === :access, logs)
282- @test occursin(r" ^application/json text/plain GET / HTTP/1\. 1 GET / 127\. 0\. 0\. 1 \d + - HTTP/1\. 1 \d {4}-\d {2}-\d {2}T\d {2}:\d {2}:\d {2}.* \d +/.*/\d {4}:\d {2}:\d {2}:\d {2}.* 200 12$" , logs[1 ]. message)
283- @test occursin(r" ^\* /\* text/plain GET /index\. html HTTP/1\. 1 GET /index\. html 127\. 0\. 0\. 1 \d + - HTTP/1\. 1 \d {4}-\d {2}-\d {2}T\d {2}:\d {2}:\d {2}.* \d +/.*/\d {4}:\d {2}:\d {2}:\d {2}.* 200 12$" , logs[2 ]. message)
284- @test occursin(r" ^\* /\* text/plain GET /index\. html\? a=b HTTP/1\. 1 GET /index\. html\? a=b 127\. 0\. 0\. 1 \d + - HTTP/1\. 1 \d {4}-\d {2}-\d {2}T\d {2}:\d {2}:\d {2}.* \d +/.*/\d {4}:\d {2}:\d {2}:\d {2}.* 200 12$" , logs[3 ]. message)
285- @test occursin(r" ^\* /\* text/plain HEAD / HTTP/1\. 1 HEAD / 127\. 0\. 0\. 1 \d + - HTTP/1\. 1 \d {4}-\d {2}-\d {2}T\d {2}:\d {2}:\d {2}.* \d +/.*/\d {4}:\d {2}:\d {2}:\d {2}.* 200 0$" , logs[4 ]. message)
289+ @test occursin(r" ^application/json text/plain GET / HTTP/1\. 1 GET / 127\. 0\. 0\. 1 \d + - HTTP/1\. 1 \d {4}-\d {2}-\d {2}T\d {2}:\d {2}:\d {2}.* \d +/.*/\d {4}:\d {2}:\d {2}:\d {2}.* 200 12 0$" , logs[1 ]. message)
290+ @test occursin(r" ^\* /\* text/plain GET /index\. html HTTP/1\. 1 GET /index\. html 127\. 0\. 0\. 1 \d + - HTTP/1\. 1 \d {4}-\d {2}-\d {2}T\d {2}:\d {2}:\d {2}.* \d +/.*/\d {4}:\d {2}:\d {2}:\d {2}.* 200 12 0$" , logs[2 ]. message)
291+ @test occursin(r" ^\* /\* text/plain GET /index\. html\? a=b HTTP/1\. 1 GET /index\. html\? a=b 127\. 0\. 0\. 1 \d + - HTTP/1\. 1 \d {4}-\d {2}-\d {2}T\d {2}:\d {2}:\d {2}.* \d +/.*/\d {4}:\d {2}:\d {2}:\d {2}.* 200 12 0$" , logs[3 ]. message)
292+ @test occursin(r" ^\* /\* text/plain HEAD / HTTP/1\. 1 HEAD / 127\. 0\. 0\. 1 \d + - HTTP/1\. 1 \d {4}-\d {2}-\d {2}T\d {2}:\d {2}:\d {2}.* \d +/.*/\d {4}:\d {2}:\d {2}:\d {2}.* 200 0 0$" , logs[4 ]. message)
293+ @test occursin(r" ^\* /\* - POST /post HTTP/1\. 1 POST /post 127\. 0\. 0\. 1 \d + - HTTP/1\. 1 \d {4}-\d {2}-\d {2}T\d {2}:\d {2}:\d {2}.* \d +/.*/\d {4}:\d {2}:\d {2}:\d {2}.* 200 0 12$" , logs[5 ]. message)
286294end
287295
288296end # module
0 commit comments