diff --git a/CHANGES.md b/CHANGES.md index a92eea1837..7d582ee4ce 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,9 @@ +# 2.2.1 (unreleased) + +Fixed: + +- Fixed HTTP response status in `output.harbor` (#3255) + # 2.2.0 (2023-07-21) New: diff --git a/src/core/harbor/harbor.ml b/src/core/harbor/harbor.ml index b93058718b..dec1ecb3a2 100644 --- a/src/core/harbor/harbor.ml +++ b/src/core/harbor/harbor.ml @@ -101,6 +101,7 @@ module type T = sig exception Unknown_codec exception Mount_taken exception Websocket_closed + exception Protocol_not_supported of string (* Generic *) @@ -383,6 +384,8 @@ module Make (T : Transport_t) : T with type socket = T.socket = struct log#info "ICY error: invalid password"; simple_reply "Invalid password\r\n\r\n")) + exception Protocol_not_supported of string + let parse_http_request_line r = try let data = Pcre.split ~rex:(Pcre.regexp "[ \t]+") r in @@ -395,10 +398,14 @@ module Make (T : Transport_t) : T with type socket = T.socket = struct | "HTTP/1.1" -> `Http_11 | "ICE/1.0" -> `Ice_10 | s when protocol = `Source -> `Xaudiocast_uri s - | _ -> raise Not_found ) - with e -> - log#info "Invalid request line %s: %s" r (Printexc.to_string e); - simple_reply "HTTP 500 Invalid request\r\n\r\n" + | s -> raise (Protocol_not_supported s) ) + with + | Protocol_not_supported p -> + log#info "Protocol not supported for request %s: %s" r p; + simple_reply "HTTP 505 Protocol Not Supported\r\n\r\n" + | e -> + log#info "Invalid request line %s: %s" r (Printexc.to_string e); + simple_reply "HTTP 500 Invalid request\r\n\r\n" let parse_headers headers = let split_header h l = diff --git a/src/core/outputs/harbor_output.ml b/src/core/outputs/harbor_output.ml index 6b15eb3909..9a76ecd875 100644 --- a/src/core/outputs/harbor_output.ml +++ b/src/core/outputs/harbor_output.ml @@ -452,7 +452,7 @@ class output p = extra_headers) in let reply = - Printf.sprintf "%s 200 OK\r\nContent-type: %s\r\n%s%s\r\n" protocol + Printf.sprintf "HTTP/%s 200 OK\r\nContent-type: %s\r\n%s%s\r\n" protocol data.format icyheader extra_headers in let buffer =