Repository: falconry/falcon
Pull request #1063 (2017-05-24 23:07:12)

added referer attribute to request
This is to fix issue : https://github.com/falconry/falcon/issues/933

codecov[bot]: # [Codecov](https://codecov.io/gh/falconry/falcon/pull/1063?src=pr&el=h1) Report
> Merging [#1063](https://codecov.io/gh/falconry/falcon/pull/1063?src=pr&el=desc) into [master](https://codecov.io/gh/falconry/falcon/commit/4578017def483dbf475591a620d26c8ca8f5748d?src=pr&el=desc) will **not change** coverage.
> The diff coverage is `100%`.

[![Impacted file tree graph](https://codecov.io/gh/falconry/falcon/pull/1063/graphs/tree.svg?token=zOtkfNQ3h6&src=pr&width=650&height=150)](https://codecov.io/gh/falconry/falcon/pull/1063?src=pr&el=tree)

```diff
@@          Coverage Diff           @@
##           master   #1063   +/-   ##
======================================
  Coverage     100%    100%           
======================================
  Files          31      31           
  Lines        2181    2182    +1     
  Branches      339     339           
======================================
+ Hits         2181    2182    +1
```


| [Impacted Files](https://codecov.io/gh/falconry/falcon/pull/1063?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [falcon/request.py](https://codecov.io/gh/falconry/falcon/pull/1063?src=pr&el=tree#diff-ZmFsY29uL3JlcXVlc3QucHk=) | `100% <100%> (ø)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/falconry/falcon/pull/1063?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/falconry/falcon/pull/1063?src=pr&el=footer). Last update [4578017...35a18d2](https://codecov.io/gh/falconry/falcon/pull/1063?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Patch:
diff --git a/falcon/request.py b/falcon/request.py
index c5d4be4..dd06bcc 100644
--- a/falcon/request.py
+++ b/falcon/request.py
@@ -169,6 +169,8 @@ class Request(object):
 
         user_agent (str): Value of the User-Agent header, or ``None`` if the
             header is missing.
+        referer (str): Value of Referer header, or ``None`` if
+            the header is missing.
         accept (str): Value of the Accept header, or '*/*' if the header is
             missing.
         auth (str): Value of the Authorization header, or ``None`` if the
@@ -437,6 +439,8 @@ class Request(object):
     if_none_match = helpers.header_property('HTTP_IF_NONE_MATCH')
     if_range = helpers.header_property('HTTP_IF_RANGE')
 
+    referer = helpers.header_property('HTTP_REFERER')
+
     @property
     def client_accepts_json(self):
         return self.client_accepts('application/json')


Test patch:
diff --git a/tests/test_req_vars.py b/tests/test_req_vars.py
index c3213f4..6451020 100644
--- a/tests/test_req_vars.py
+++ b/tests/test_req_vars.py
@@ -622,6 +622,7 @@ class TestReqVars(testing.TestCase):
         auth = 'HMAC_SHA1 c590afa9bb59191ffab30f223791e82d3fd3e3af'
         agent = 'testing/1.0.1'
         default_agent = 'curl/7.24.0 (x86_64-apple-darwin12.0)'
+        referer = 'https://www.google.com/'
 
         self._test_attribute_header('Accept', 'x-falcon', 'accept',
                                     default='*/*')
@@ -638,6 +639,7 @@ class TestReqVars(testing.TestCase):
 
         self._test_attribute_header('User-Agent', agent, 'user_agent',
                                     default=default_agent)
+        self._test_attribute_header('Referer', referer, 'referer')
 
     def test_method(self):
         self.assertEqual(self.req.method, 'GET')