(* "version code reason_phrase" *)
object (self)
+ (* note that response objects can't be created with a None version *)
inherit
- Http_message.message ~body ~headers ~version ~clisockaddr ~srvsockaddr
+ Http_message.message
+ ~body ~headers ~version:(Some version) ~clisockaddr ~srvsockaddr
val mutable _code =
match status with
| Some (s: Http_types.status) -> code_of_status s
val mutable _reason: string option = None
+ method private getRealVersion =
+ match self#version with
+ | None ->
+ failwith ("Http_response.fstLineToString: " ^
+ "can't serialize an HTTP response with no HTTP version defined")
+ | Some v -> string_of_version v
+
method code = _code
method setCode c =
ignore (status_of_code c); (* sanity check on c *)
| Some r -> r
method setReason r = _reason <- Some r
method statusLine =
- String.concat
- " "
- [string_of_version self#version; string_of_int self#code; self#reason]
+ String.concat " "
+ [self#getRealVersion; string_of_int self#code; self#reason]
method setStatusLine s =
try
let subs = Pcre.extract ~rex:status_line_RE s in
method setServer s = self#replaceHeader "Server" s
method private fstLineToString =
- sprintf
- "%s %d %s"
- (string_of_version self#version)
- self#code
- self#reason
+ sprintf "%s %d %s" self#getRealVersion self#code self#reason
end