2

In my pyramid view i want to get HTTP_REFERER so first i tried self.request.environ.get('HTTP_REFERRER') in first time it was working fine but letter it start giving me empty/none.

then i tried all the way like

self.request.environ.get('HTTP_REFERRER')

self.request.referrer

self.request.url

and all still i am not getting HTTP_REFERRER even there is no key in self.request.environ

i changed browser setting also inside about:config then network.http.sendRefferHeader then also i could not solve my problem

and in my case none of the condit

entered the site URL in browser address bar itself.

visited the site by a browser-maintained bookmark.

visited the site as first page in the window/tab.

visited the site programmatically (like, curl) without setting the referrer header (searchbots!).

and all

Please suggest me how to get HTTP_REFERER

i am using pyramid and pylons framwork pylons api calling pyramid api.

1 Answers1

-1

The browser does not always send referrer header. Please check Wikipedia HTTP Referrer page for more information about the behavior. If the browser doesn't send this header, or it is stripped off by proxy, web server or whatever then the value is not set.

request.referrer is the correct way to access this field in Pyramid / WebOb based HTTPRequest objects.

Mikko Ohtamaa
  • 82,057
  • 50
  • 264
  • 435