You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On Nov 26, 2016, at 3:55 PM, Marek Kubica ***@***.***> wrote:
When calling the redirect function, the location header is set, but the return code stays 200, which is (at least for me, possibly others) confusing.
The following fairly minimal example illustrates the issue:
open Cohttp_lwt_unix
open Lwt.Infix
module Wm = struct
module Rd = Webmachine.Rd
include Webmachine.Make(Cohttp_lwt_unix_io)
end
class redirect () = object(self)
inherit [Cohttp_lwt_body.t] Wm.resource
method private to_json rd =
Wm.Rd.redirect "#62" rd
|> Wm.continue `Empty
method content_types_provided rd =
Wm.continue [
"application/json", self#to_json
] rd
method content_types_accepted rd =
Wm.continue [] rd
end
let main () =
let port = 8080 in
let routes = [
("/", fun () -> new redirect ()) ;
] in
let callback (ch,conn) request body =
let open Cohttp in
Wm.dispatch' routes ~body ~request
>|= (function
| None -> (`Not_found, Header.init (), `String "Not found", [])
| Some result -> result)
>>= fun (status, headers, body, path) ->
Server.respond ~headers ~body ~status ()
in
let config = Server.make ~callback () in
Server.create ~mode:(`TCP(`Port port)) config
>>= fun () -> Lwt.return_unit
let () = Lwt_main.run @@ main ()
Request from the running server via curl -v localhost:8080/ and see that the location header is sent but the return code stays 200.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.
When calling the
redirect
function, thelocation
header is set, but the return code stays 200, which is (at least for me, possibly others) confusing.The following fairly minimal example illustrates the issue:
Request from the running server via
curl -v localhost:8080/
and see that thelocation
header is sent but the return code stays 200.The text was updated successfully, but these errors were encountered: