Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ Unreleased
([#140](https://github.com/anmonteiro/httpun/pull/140))
- types: add `Headers.singleton`
([#146](https://github.com/anmonteiro/httpun/pull/146))
- server: only set response to upgraded after flushing response bytes
([#143](https://github.com/anmonteiro/httpun/pull/143))

0.2.0 2024-09-04
--------------
Expand Down
6 changes: 3 additions & 3 deletions lib/reqd.ml
Original file line number Diff line number Diff line change
Expand Up @@ -191,15 +191,15 @@ let unsafe_respond_with_upgrade t headers upgrade_handler =
let response = Response.create ~headers `Switching_protocols in
Writer.write_response t.writer response;
if t.persistent then t.persistent <- Response.persistent_connection response;
t.response_state <- Upgrade response;
Writer.flush t.writer (fun _reason ->
t.response_state <- Upgrade response;
(* TODO(anmonteiro): probably need to check `Closed here? *)
upgrade_handler ());
Body.Reader.close t.request_body;
Writer.wakeup t.writer
| Streaming _ | Upgrade _ ->
| Streaming _ ->
failwith "httpun.Reqd.unsafe_respond_with_upgrade: response already started"
| Fixed _ ->
| Fixed _ | Upgrade _ ->
failwith
"httpun.Reqd.unsafe_respond_with_upgrade: response already complete"

Expand Down