Merge lp:~vila/bzr/665100-content-type into lp:bzr

Proposed by Vincent Ladeuil
Status: Merged
Approved by: John A Meinel
Approved revision: no longer in the source branch.
Merged at revision: 5515
Proposed branch: lp:~vila/bzr/665100-content-type
Merge into: lp:bzr
Diff against target: 57 lines (+12/-3)
4 files modified
bzrlib/tests/test_http.py (+2/-0)
bzrlib/transport/http/_pycurl.py (+3/-1)
bzrlib/transport/http/_urllib.py (+4/-2)
doc/en/release-notes/bzr-2.3.txt (+3/-0)
To merge this branch: bzr merge lp:~vila/bzr/665100-content-type
Reviewer Review Type Date Requested Status
bzr-core Pending
Review via email: mp+39194@code.launchpad.net

Commit message

Correctly set the Content-Type header when POSTing http requests.

Description of the change

Amazingly we have never set the Content-Type header for the http POST requests...

It turns out we should. The fix is pretty trivial and we even had a test waiting for us to add the appropriate check :)

To post a comment you must log in.
Revision history for this message
Vincent Ladeuil (vila) wrote :

sent to pqm by email

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bzrlib/tests/test_http.py'
2--- bzrlib/tests/test_http.py 2010-10-18 10:01:47 +0000
3+++ bzrlib/tests/test_http.py 2010-10-23 08:42:50 +0000
4@@ -507,6 +507,8 @@
5 self.assertTrue(
6 server.received_bytes.startswith('POST /.bzr/smart HTTP/1.'))
7 self.assertTrue('content-length: 19\r' in server.received_bytes.lower())
8+ self.assertTrue('content-type: application/octet-stream\r'
9+ in server.received_bytes.lower())
10 # The transport should not be assuming that the server can accept
11 # chunked encoding the first time it connects, because HTTP/1.1, so we
12 # check for the literal string.
13
14=== modified file 'bzrlib/transport/http/_pycurl.py'
15--- bzrlib/transport/http/_pycurl.py 2010-10-08 04:38:25 +0000
16+++ bzrlib/transport/http/_pycurl.py 2010-10-23 08:42:50 +0000
17@@ -268,7 +268,9 @@
18 # We override the Expect: header so that pycurl will send the POST
19 # body immediately.
20 try:
21- self._curl_perform(curl, header, ['Expect: '])
22+ self._curl_perform(curl, header,
23+ ['Expect: ',
24+ 'Content-Type: application/octet-stream'])
25 except pycurl.error, e:
26 if e[0] == CURLE_SEND_ERROR:
27 # When talking to an HTTP/1.0 server, getting a 400+ error code
28
29=== modified file 'bzrlib/transport/http/_urllib.py'
30--- bzrlib/transport/http/_urllib.py 2010-06-01 13:01:20 +0000
31+++ bzrlib/transport/http/_urllib.py 2010-10-23 08:42:50 +0000
32@@ -138,8 +138,10 @@
33 abspath = self._remote_path('.bzr/smart')
34 # We include 403 in accepted_errors so that send_http_smart_request can
35 # handle a 403. Otherwise a 403 causes an unhandled TransportError.
36- response = self._perform(Request('POST', abspath, body_bytes,
37- accepted_errors=[200, 403]))
38+ response = self._perform(
39+ Request('POST', abspath, body_bytes,
40+ {'Content-Type': 'application/octet-stream'},
41+ accepted_errors=[200, 403]))
42 code = response.code
43 data = handle_response(abspath, code, response.info(), response)
44 return code, data
45
46=== modified file 'doc/en/release-notes/bzr-2.3.txt'
47--- doc/en/release-notes/bzr-2.3.txt 2010-10-21 07:51:44 +0000
48+++ doc/en/release-notes/bzr-2.3.txt 2010-10-23 08:42:50 +0000
49@@ -49,6 +49,9 @@
50 * ``bzr status -r X..Y`` was failing because RevisionTree didn't implement
51 ``get_shelf_manager``. (John Arbash Meinel, #662053)
52
53+* Correctly set the Content-Type header when http POSTing to comply
54+ with stricter web frameworks. (Vincent Ladeuil, #655100)
55+
56 * Don't force openssh to use protocol=2, since that is now the default.
57 (Neil Martinsen-Burrell, #561061)
58