~ubuntu-branches/ubuntu/lucid/lazr.restfulclient/lucid-proposed

« back to all changes in this revision

Viewing changes to debian/patches/uppercase-method.patch

  • Committer: Package Import Robot
  • Author(s): Colin Watson
  • Date: 2014-12-11 16:30:02 UTC
  • Revision ID: package-import@ubuntu.com-20141211163002-9esry51vksl1z3hd
Tags: 0.9.11-1ubuntu1.4
Always uppercase HTTP methods to match httplib2 expectations
(LP: #1401544).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
Description: Always uppercase HTTP methods to match httplib2 expectations
 
2
Origin: backport, http://bazaar.launchpad.net/~lazr-developers/lazr.restfulclient/trunk/revision/121
 
3
Bug-Ubuntu: https://bugs.launchpad.net/bugs/1401544
 
4
Last-Update: 2014-12-11
 
5
 
 
6
Index: b/src/lazr/restfulclient/docs/entries.txt
 
7
===================================================================
 
8
--- a/src/lazr/restfulclient/docs/entries.txt
 
9
+++ b/src/lazr/restfulclient/docs/entries.txt
 
10
@@ -542,14 +542,14 @@
 
11
 request.
 
12
 
 
13
     >>> recipes = cookbook.find_recipes(search="foo")
 
14
-    send: 'get /1.0/cookbooks/...ws.op=find_recipes...'
 
15
+    send: 'GET /1.0/cookbooks/...ws.op=find_recipes...'
 
16
     ...
 
17
 
 
18
 Even dereferencing an entry from another entry and then invoking a
 
19
 named operation causes only one HTTP request.
 
20
 
 
21
     >>> recipes = recipe1.cookbook.find_recipes(search="bar")
 
22
-    send: 'get /1.0/cookbooks/...ws.op=find_recipes...'
 
23
+    send: 'GET /1.0/cookbooks/...ws.op=find_recipes...'
 
24
     ...
 
25
 
 
26
 In all cases we are able to delay HTTP requests until the moment we
 
27
Index: b/src/lazr/restfulclient/resource.py
 
28
===================================================================
 
29
--- a/src/lazr/restfulclient/resource.py
 
30
+++ b/src/lazr/restfulclient/resource.py
 
31
@@ -523,8 +523,15 @@
 
32
              in_representation) = self.wadl_method.build_representation(
 
33
                 **args)
 
34
             extra_headers = { 'Content-type' : media_type }
 
35
+        # Pass uppercase method names to httplib2, as that is what it works
 
36
+        # with. If you pass a lowercase method name to httplib then it doesn't
 
37
+        # consider it to be a GET, PUT, etc., and so will do things like not
 
38
+        # cache. Wadl Methods return their method lower cased, which is how it
 
39
+        # is compared in this method, but httplib2 expects the opposite, hence
 
40
+        # the .upper() call.
 
41
         response, content = self.root._browser._request(
 
42
-            url, in_representation, http_method, extra_headers=extra_headers)
 
43
+            url, in_representation, http_method.upper(),
 
44
+            extra_headers=extra_headers)
 
45
 
 
46
         if response.status == 201:
 
47
             return self._handle_201_response(url, response, content)