0

$_SERVER[HTTP_REFERER] allows one to retrieve the referring URL in PHP, how to do the same in Haskell?

Chris Stryczynski
  • 30,145
  • 48
  • 175
  • 286
x4rkz
  • 513
  • 4
  • 19
  • 1
    What have you tried, can you include some code, [etc.](https://stackoverflow.com/help/mcve). Aside: you probably want [this](https://hackage.haskell.org/package/wai-3.2.1.1/docs/Network-Wai.html#v:requestHeaderReferer), but that requires you to parse the header yourself. – user2407038 Jun 12 '17 at 01:00
  • 1
    Can't you use the `header` function provided in `scotty` [here](https://hackage.haskell.org/package/scotty-0.11.0/docs/Web-Scotty.html#v:header)? E.g. `url <- header "referer"`? Note that `url` will then be of type `Maybe Text`. – liminalisht Jun 12 '17 at 03:35
  • Thank you, it was just that. I didn't know this information was in the header so I didn't look in that direction. – x4rkz Jun 12 '17 at 10:19
  • @liminalisht can you please write an actual answer, then it can be accepted get taken off the unanswered list – Julian Leviston Jun 18 '17 at 12:04

1 Answers1

1

The http_referer is stored in the HTTP header, which means that you can retrieve it using the header function of scotty like this:

url <- header "referer"
x4rkz
  • 513
  • 4
  • 19