diff --git a/CHANGES.md b/CHANGES.md index ba32903d..807f73d1 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -55,6 +55,11 @@ Unreleased [inhabitedtype/httpaf#162](https://github.com/inhabitedtype/httpaf/issues/162) - httpaf-async: Add HTTPS support for the Async bindings ([#35](https://github.com/anmonteiro/httpaf/pull/35)). +- httpaf: Fix upstream regression introduced in + [inhabitedtype/httpaf#161](https://github.com/inhabitedtype/httpaf/pull/161) + that caused `wake_up_writer` callback bookkeeping to be slightly wrong due to + physical equality, producing runtime errors in cases where it shouldn't + ([#37](https://github.com/anmonteiro/httpaf/pull/37)). httpaf (upstream) 0.6.5 -------------- diff --git a/lib_test/test_server_connection.ml b/lib_test/test_server_connection.ml index e724d669..a61ec3ac 100644 --- a/lib_test/test_server_connection.ml +++ b/lib_test/test_server_connection.ml @@ -723,6 +723,28 @@ let test_empty_body_no_immediate_flush () = true !reader_woken_up; ;; +let test_yield_before_starting_a_response () = + let reader_woken_up = ref false in + let response = Response.create `OK in + let continue_response = ref (fun () -> ()) in + let request_handler reqd = + continue_response := (fun () -> + let resp_body = Reqd.respond_with_streaming reqd response in + Body.close_writer resp_body) + in + let t = create ~error_handler request_handler in + reader_ready t; + writer_yielded t; + read_request t (Request.create `GET "/"); + yield_reader t (fun () -> reader_woken_up := true); + yield_writer t ignore; + !continue_response (); + write_response t ~body:"" response; + writer_yielded t; + Alcotest.(check bool) "Reader woken up" + true !reader_woken_up; +;; + let tests = [ "initial reader state" , `Quick, test_initial_reader_state ; "shutdown reader closed", `Quick, test_reader_is_closed_after_eof @@ -750,4 +772,5 @@ let tests = ; "malformed request, streaming response", `Quick, test_malformed_request_streaming_error_response ; "`flush_headers_immediately` with empty body", `Quick, test_immediate_flush_empty_body ; "empty body with no immediate flush", `Quick, test_empty_body_no_immediate_flush + ; "yield before starting a response", `Quick, test_yield_before_starting_a_response ]