change redirect content type
This commit is contained in:
parent
f9ee533917
commit
531538cc3f
@ -86,13 +86,16 @@ end = struct
|
||||
let target = List.filter (fun s -> s <> "") target in
|
||||
let target = Array.of_list target in
|
||||
let response = handler target request in
|
||||
let status, content =
|
||||
let status, content, status_headers =
|
||||
match response with
|
||||
| Ok content -> (`OK, content)
|
||||
| Ok content -> (`OK, content, [])
|
||||
| Error (((See_other redirect | Found redirect | Moved_permanently redirect) as status), content) ->
|
||||
let status = Status.to_httpcats status in
|
||||
status, Content.Html content, [ "Location", redirect ]
|
||||
| Error (status, content) ->
|
||||
let status = Status.to_httpcats status in
|
||||
let content = Content.Html content in
|
||||
(status, content)
|
||||
(status, content, [])
|
||||
in
|
||||
let session = Session.load request in
|
||||
let session_headers =
|
||||
@ -100,7 +103,7 @@ end = struct
|
||||
in
|
||||
let headers, content = prepare_content content in
|
||||
let headers = H2.Headers.to_list headers in
|
||||
let headers = session_headers @ headers in
|
||||
let headers = session_headers @ headers @ status_headers in
|
||||
let headers = H2.Headers.of_list headers in
|
||||
Httpcats.Server.string ~headers ~status content
|
||||
in
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
type error =
|
||||
| Moved_permanently
|
||||
| Moved_permanently of string
|
||||
| Found of string
|
||||
| See_other of string
|
||||
| Bad_request
|
||||
| Unauthorized
|
||||
| Forbidden
|
||||
@ -13,7 +15,9 @@ type error =
|
||||
| Gateway_timeout
|
||||
|
||||
let to_httpcats = function
|
||||
| Moved_permanently -> `Moved_permanently
|
||||
| Moved_permanently _url -> `Moved_permanently
|
||||
| Found _url -> `Found
|
||||
| See_other _url -> `See_other
|
||||
| Bad_request -> `Bad_request
|
||||
| Unauthorized -> `Unauthorized
|
||||
| Forbidden -> `Forbidden
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
type error =
|
||||
| Moved_permanently
|
||||
| Moved_permanently of string
|
||||
| Found of string
|
||||
| See_other of string
|
||||
| Bad_request
|
||||
| Unauthorized
|
||||
| Forbidden
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user