mirror of
https://github.com/c-cube/tiny_httpd.git
synced 2025-12-06 03:05:29 -05:00
fix: give the correct code+error if protocol upgrade fails
This commit is contained in:
parent
284d1f7400
commit
e5191f0fd7
1 changed files with 10 additions and 8 deletions
|
|
@ -364,7 +364,6 @@ let client_handle_for (self : t) ~client_addr ic oc : unit =
|
|||
|
||||
let handle_upgrade ~(middlewares : Head_middleware.t list) req
|
||||
(module UP : UPGRADE_HANDLER) : unit =
|
||||
try
|
||||
Log.debug (fun k -> k "upgrade connection");
|
||||
|
||||
let send_resp resp =
|
||||
|
|
@ -372,6 +371,7 @@ let client_handle_for (self : t) ~client_addr ic oc : unit =
|
|||
Response.Private_.output_ ~bytes:bytes_res oc resp
|
||||
in
|
||||
|
||||
try
|
||||
(* apply head middlewares *)
|
||||
let req = List.fold_left Head_middleware.apply' req middlewares in
|
||||
|
||||
|
|
@ -399,7 +399,9 @@ let client_handle_for (self : t) ~client_addr ic oc : unit =
|
|||
|
||||
(* handshake successful, proceed with the upgrade handler *)
|
||||
UP.handle_connection handshake_st ic oc
|
||||
with e ->
|
||||
with
|
||||
| Bad_req (code, err) -> send_resp @@ Response.make_raw ~code err
|
||||
| e ->
|
||||
let bt = Printexc.get_raw_backtrace () in
|
||||
handle_bad_req req e bt
|
||||
in
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue