Skip to content

Commit

Permalink
Limit Dream.redirect ?status to redirections (#130)
Browse files Browse the repository at this point in the history
  • Loading branch information
thangngoc89 committed Jul 15, 2021
1 parent 48cc4d4 commit 0818d2f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/dream.mli
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ val json :
{!Dream.application_json}. *)

val redirect :
?status:status ->
?status:redirection ->
?code:int ->
?headers:(string * string) list ->
request -> string -> response promise
Expand All @@ -460,7 +460,9 @@ val redirect :
redirection. Use [~status:`Moved_Permanently] or [~code:301] for a permanent
redirection. The {!type-request} is used for retrieving the site prefix, if
the string is an absolute path. Most applications don't have a site
prefix. *)
prefix.
Warning: Browsers don't redirect if status code isn't 30x. *)

val empty :
?headers:(string * string) list ->
Expand Down
1 change: 1 addition & 0 deletions src/pure/inmost.ml
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,7 @@ let redirect ?status ?code ?headers _request location =
| None, None -> Some (`See_Other)
| _ -> status
in
let status = (status :> status option) in
response ?status ?code ?headers location
|> with_header "Location" location
|> Lwt.return
Expand Down

0 comments on commit 0818d2f

Please sign in to comment.