Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Setting an header from a request object was broken

When setting an header for a request object, the client was using the
old API and was throwing an exception. Now it uses the new API.

Added a test.

Signed-off-by: franck cuny <franck.cuny@gmail.com>
  • Loading branch information...
commit bd0666f244ae6709ce888a5e8b8e442d0198c8cb 1 parent 1e0a484
Franck Cuny authored February 07, 2012
2  http/request.py
@@ -55,7 +55,7 @@ def header(self, name, value=None):
55 55
         if value is None:
56 56
             return self._headers.get(name)
57 57
         else:
58  
-            self._headers[name] = value
  58
+            self._headers.add(name, value)
59 59
 
60 60
     @property
61 61
     def headers(self):
11  tests/test_request.py
@@ -22,15 +22,22 @@ def test_method(self):
22 22
         self.assertEqual(request.method, 'post')
23 23
 
24 24
     def test_headers(self):
25  
-        request = Request('GET', 'http', {'Connection':'keep-alive'})
  25
+        request = Request('GET', 'http', {'Connection': 'keep-alive'})
26 26
         self.assertIsInstance(request.headers, Headers)
27 27
 
28  
-        headers = Headers({'Connection':'keep-alive'})
  28
+        headers = Headers({'Connection': 'keep-alive'})
29 29
         request = Request('GET', 'http', headers)
30 30
         self.assertTrue(request)
31 31
 
32 32
         self.assertEqual(request.header('connection'), 'keep-alive')
33 33
 
  34
+    def test_header(self):
  35
+        request = Request('GET', 'http://lumberjaph.net')
  36
+        request.header('If-Modified-Since',
  37
+            'Wed, 08 Feb 2012 05:08:50 GMT')
  38
+        self.assertEqual(request.header('If-Modified-Since'),
  39
+            'Wed, 08 Feb 2012 05:08:50 GMT')
  40
+
34 41
     def test_url(self):
35 42
         request = Request('GET', 'http')
36 43
         self.assertIsInstance(request.url, Url)

0 notes on commit bd0666f

Please sign in to comment.
Something went wrong with that request. Please try again.