diff options
| author | Adrian Teng <adrian@teng.io> | 2014-12-17 00:06:27 +0000 |
|---|---|---|
| committer | Adrian Teng <adrian@teng.io> | 2014-12-17 00:46:31 +0000 |
| commit | 2711913daac645dc1960074d6c5121c8fb49b772 (patch) | |
| tree | 4ea4dcddda9efc17294e007d084c3dca88aec442 | |
| parent | cc15bbf7de74f4cdfc676e34fa429d2658d1ddf6 (diff) | |
| download | pyramid-2711913daac645dc1960074d6c5121c8fb49b772.tar.gz pyramid-2711913daac645dc1960074d6c5121c8fb49b772.tar.bz2 pyramid-2711913daac645dc1960074d6c5121c8fb49b772.zip | |
Add documentation on handling CORS pre-flights
| -rw-r--r-- | CONTRIBUTORS.txt | 2 | ||||
| -rw-r--r-- | docs/narr/webob.rst | 4 |
2 files changed, 6 insertions, 0 deletions
diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt index 9c2191f3b..e4132cda5 100644 --- a/CONTRIBUTORS.txt +++ b/CONTRIBUTORS.txt @@ -236,3 +236,5 @@ Contributors - Randall Leeds, 2014/11/11 - Hugo Branquinho, 2014/11/25 + +- Adrian Teng, 2014/12/17 diff --git a/docs/narr/webob.rst b/docs/narr/webob.rst index 6a331e4bf..7d459a1f5 100644 --- a/docs/narr/webob.rst +++ b/docs/narr/webob.rst @@ -310,6 +310,10 @@ Python's ``urllib2`` instead of a Javascript AJAX request: req = urllib2.Request('http://localhost:6543/', json_payload, headers) resp = urllib2.urlopen(req) +If you are doing Cross-origin resource sharing (CORS), then the standard requires the browser to do a pre-flight HTTP OPTIONS request. The easiest way to handling this is adding an extra ``view_config`` for the same route, with ``request_method`` set to ``OPTIONS``, and setting the desired response header before returning. You can find examples of response headers here_. + +.. _here: https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS#Preflighted_requests + .. index:: single: cleaning up after request |
