fmt
This commit is contained in:
parent
2847432240
commit
f4d9f8e618
8 changed files with 124 additions and 55 deletions
31
server.ml
31
server.ml
|
|
@ -66,7 +66,7 @@ let transmit_random ~write_string ~flush ~close_writer
|
|||
| 0L -> finalize ctx (Base64_rfc2045.encode encoder `End)
|
||||
| length ->
|
||||
let len = min (Int64.of_int (Cstruct.length rnd)) length in
|
||||
let ({ Cstruct.buffer; off; len = buffer_len } as rnd) =
|
||||
let ({ Cstruct.buffer; off; len= buffer_len } as rnd) =
|
||||
random_cstruct ~g rnd (Int64.to_int len)
|
||||
in
|
||||
Log.debug (fun m ->
|
||||
|
|
@ -115,7 +115,7 @@ let hash ~version ~create ?seed length =
|
|||
(response, Digestif.SHA256.(to_hex (get ctx)))
|
||||
| length ->
|
||||
let len = min (Int64.of_int (Cstruct.length rnd)) length in
|
||||
let { Cstruct.buffer; off; len = buffer_len } =
|
||||
let { Cstruct.buffer; off; len= buffer_len } =
|
||||
random_cstruct ~g rnd (Int64.to_int len)
|
||||
in
|
||||
Log.debug (fun m ->
|
||||
|
|
@ -257,7 +257,7 @@ module S_HTTP_1_1 = struct
|
|||
|
||||
let with_etag etag response =
|
||||
let headers = response.H1.Response.headers in
|
||||
{ response with H1.Response.headers = H1.Headers.add headers "etag" etag }
|
||||
{ response with H1.Response.headers= H1.Headers.add headers "etag" etag }
|
||||
|
||||
let with_status (status : H2.Status.t) response =
|
||||
match status with
|
||||
|
|
@ -266,9 +266,7 @@ module S_HTTP_1_1 = struct
|
|||
end
|
||||
|
||||
let transmit src dst =
|
||||
let rec on_eof () =
|
||||
H1.Body.Reader.close src;
|
||||
H1.Body.Writer.close dst
|
||||
let rec on_eof () = H1.Body.Reader.close src; H1.Body.Writer.close dst
|
||||
and on_read buf ~off ~len =
|
||||
H1.Body.Writer.write_bigstring dst ~off ~len buf;
|
||||
H1.Body.Reader.schedule_read src ~on_eof ~on_read
|
||||
|
|
@ -300,8 +298,7 @@ let connect_http_1_1 ~ctx ~authenticator ~to_close flow reqd =
|
|||
H1.Headers.of_list
|
||||
[
|
||||
("content-length", string_of_int (String.length contents));
|
||||
("connection", "close");
|
||||
("content-type", "text/plain");
|
||||
("connection", "close"); ("content-type", "text/plain");
|
||||
]
|
||||
in
|
||||
let response =
|
||||
|
|
@ -315,8 +312,7 @@ let connect_http_1_1 ~ctx ~authenticator ~to_close flow reqd =
|
|||
H1.Headers.of_list
|
||||
[
|
||||
("content-length", string_of_int (String.length contents));
|
||||
("connection", "close");
|
||||
("content-type", "text/plain");
|
||||
("connection", "close"); ("content-type", "text/plain");
|
||||
]
|
||||
in
|
||||
let response =
|
||||
|
|
@ -341,8 +337,7 @@ let http_1_1_request_handler ~ctx ~authenticator ~to_close =
|
|||
H1.Headers.of_list
|
||||
[
|
||||
("content-length", string_of_int (String.length root));
|
||||
("connection", "close");
|
||||
("content-type", "text/plain");
|
||||
("connection", "close"); ("content-type", "text/plain");
|
||||
]
|
||||
in
|
||||
let response = H1.Response.create ~reason:"root" ~headers `OK in
|
||||
|
|
@ -401,8 +396,7 @@ let http_1_1_request_handler ~ctx ~authenticator ~to_close =
|
|||
H1.Headers.of_list
|
||||
[
|
||||
("content-length", string_of_int (String.length contents));
|
||||
("connection", "close");
|
||||
("content-type", "text/plain");
|
||||
("connection", "close"); ("content-type", "text/plain");
|
||||
]
|
||||
in
|
||||
let response =
|
||||
|
|
@ -414,8 +408,7 @@ let http_1_1_request_handler ~ctx ~authenticator ~to_close =
|
|||
let headers =
|
||||
H1.Headers.of_list
|
||||
[
|
||||
("content-type", "text/plain");
|
||||
("connection", "close");
|
||||
("content-type", "text/plain"); ("connection", "close");
|
||||
("content-length", string_of_int (String.length contents));
|
||||
]
|
||||
in
|
||||
|
|
@ -438,15 +431,13 @@ module S_HTTP_2_0 = struct
|
|||
|
||||
let with_etag etag response =
|
||||
let headers = response.H2.Response.headers in
|
||||
{ response with H2.Response.headers = H2.Headers.add headers "etag" etag }
|
||||
{ response with H2.Response.headers= H2.Headers.add headers "etag" etag }
|
||||
|
||||
let with_status status response = { response with H2.Response.status }
|
||||
end
|
||||
|
||||
let transmit src dst =
|
||||
let rec on_eof () =
|
||||
H2.Body.Reader.close src;
|
||||
H2.Body.Writer.close dst
|
||||
let rec on_eof () = H2.Body.Reader.close src; H2.Body.Writer.close dst
|
||||
and on_read buf ~off ~len =
|
||||
H2.Body.Writer.write_bigstring dst ~off ~len buf;
|
||||
H2.Body.Reader.schedule_read src ~on_eof ~on_read
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue