summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
Diffstat (limited to 'docs')
-rw-r--r--docs/narr/webob.rst14
1 files changed, 14 insertions, 0 deletions
diff --git a/docs/narr/webob.rst b/docs/narr/webob.rst
index 6e8c39523..106024db3 100644
--- a/docs/narr/webob.rst
+++ b/docs/narr/webob.rst
@@ -296,6 +296,20 @@ For the above view, printed to the console will be:
{u'a': 1}
+For bonus points, here's a bit of client-side code that will produce a
+request that has a body suitable for reading via ``request.json_body`` using
+Python's ``urllib2`` instead of a Javascript AJAX request:
+
+.. code-block:: python
+
+ import urllib2
+ import json
+
+ json_payload = json.dumps({'a':1})
+ headers = {'Content-Type':'application/json; charset=utf-8'}
+ req = urllib2.Request('http://localhost:6543/', json_payload, headers)
+ resp = urllib2.urlopen(req)
+
More Details
++++++++++++