Skip to content
Merged
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
10 changes: 5 additions & 5 deletions async/cohttp_async.ml
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ module Server = struct
>>= fun response ->
response wr

let respond ?(flush=false) ?headers ~body status : response =
let respond ?(flush=false) ?headers ?body status : response =
fun wr ->
let headers = Cohttp.Header.add_opt headers "connection" "close" in
match body with
Expand Down Expand Up @@ -269,15 +269,15 @@ module Server = struct
Writer.close wr

let respond_with_pipe ?flush ?headers ?(code=`OK) body =
return (respond ?flush ?headers ~body:(Some body) code)
return (respond ?flush ?headers ~body code)

let respond_with_string ?flush ?headers ?(code=`OK) body =
let body = Pipe.of_list [body] in
return (respond ?flush ?headers ~body:(Some body) code)
return (respond ?flush ?headers ~body code)

let respond_with_redirect ?headers uri =
let headers = Cohttp.Header.add_opt headers "location" (Uri.to_string uri) in
return (respond ~flush:false ~headers ~body:None `Found)
return (respond ~flush:false ~headers `Found)

let resolve_local_file ~docroot ~uri =
(* This normalises the Uri and strips out .. characters *)
Expand All @@ -293,7 +293,7 @@ module Server = struct
Reader.open_file filename
>>= fun rd ->
let body = Reader.pipe rd in
return (respond ?flush ?headers ~body:(Some body) `OK)
return (respond ?flush ?headers ~body `OK)
)
>>= function
|Ok res -> return res
Expand Down
2 changes: 1 addition & 1 deletion async/cohttp_async.mli
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ module Server : sig
val respond :
?flush:bool ->
?headers:Cohttp.Header.t ->
body:string Pipe.Reader.t option ->
?body:string Pipe.Reader.t ->
Cohttp.Code.status_code -> response

(** Resolve a URI and a docroot into a concrete local filename. *)
Expand Down