ocsigen / ocsigenserver

Web server in OCaml.
http://ocsigen.org/ocsigenserver/
Other
100 stars 31 forks source link

No access to X-Forwarded-For or to arbitrary headers #155

Open adrien-n opened 6 years ago

adrien-n commented 6 years ago

Hi,

I have been trying to retrieve the X-Forwarded-For header and have failed to find a dedicated API so far (like there is for Host). I haven't seen a way to access a header by name (I was looking for a function of type string -> string (option)). It seems to me that the information is not accessible and actually not even stored. Could such accessors be added? I'm sorry if this already exists and I have merely not spotted it.

vouillon commented 6 years ago

You can do this:

Http_headers.find (Http_headers.name "X-Forwarded-For")
        hds.Ocsigen_http_frame.Http_header.headers

From Eliom, you can get the header with:

let hds = Eliom_request_info.get_http_header () in