Merge lp:~cjwatson/launchpad/xmlrpc-allow-parameters into lp:launchpad

Proposed by Colin Watson
Status: Merged
Merged at revision: 17847
Proposed branch: lp:~cjwatson/launchpad/xmlrpc-allow-parameters
Merge into: lp:launchpad
Diff against target: 42 lines (+13/-1)
2 files modified
lib/lp/services/webapp/doc/webapp-publication.txt (+12/-0)
lib/lp/services/webapp/servers.py (+1/-1)
To merge this branch: bzr merge lp:~cjwatson/launchpad/xmlrpc-allow-parameters
Reviewer Review Type Date Requested Status
William Grant code Approve
Review via email: mp+277526@code.launchpad.net

Commit message

Accept XML-RPC requests with parameters in their Content-Type.

Description of the change

git.qastaging.paddev.net broke after upgrading to Twisted 15.4.0. The problem is that Twisted 15.3.0 changed (as part of a Python 3 port of twisted.web.xmlrpc) to sending "Content-Type: text/xml; charset=utf-8" in XML-RPC requests rather than just "Content-Type: text/xml", and Launchpad is excessively picky about this. There's no reason not to accept parameters in Content-Type here.

To post a comment you must log in.
Revision history for this message
William Grant (wgrant) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/services/webapp/doc/webapp-publication.txt'
2--- lib/lp/services/webapp/doc/webapp-publication.txt 2014-09-01 03:41:31 +0000
3+++ lib/lp/services/webapp/doc/webapp-publication.txt 2015-11-16 03:40:49 +0000
4@@ -395,6 +395,12 @@
5 PublicXMLRPCPublication
6
7 >>> print_request_and_publication(
8+ ... 'xmlrpc.launchpad.dev', method='POST',
9+ ... mime_type='text/xml; charset=utf-8')
10+ PublicXMLRPCRequest
11+ PublicXMLRPCPublication
12+
13+ >>> print_request_and_publication(
14 ... 'xmlrpc.launchpad.dev', method='GET')
15 ProtocolErrorRequest
16 ProtocolErrorPublication: status=405
17@@ -429,6 +435,12 @@
18 PrivateXMLRPCRequest
19 PrivateXMLRPCPublication
20
21+ >>> print_request_and_publication(
22+ ... 'xmlrpc-private.launchpad.dev', port=private_port, method='POST',
23+ ... mime_type='text/xml; charset=utf-8')
24+ PrivateXMLRPCRequest
25+ PrivateXMLRPCPublication
26+
27 A request to an unknown host results in a 404 error.
28
29 >>> print_request_and_publication('nosuchhost.launchpad.dev')
30
31=== modified file 'lib/lp/services/webapp/servers.py'
32--- lib/lp/services/webapp/servers.py 2015-10-11 20:06:23 +0000
33+++ lib/lp/services/webapp/servers.py 2015-11-16 03:40:49 +0000
34@@ -419,7 +419,7 @@
35 environment))
36 if request_factory is None:
37 mime_type = environment.get('CONTENT_TYPE')
38- if mime_type != 'text/xml':
39+ if mime_type.split(';')[0].strip() != 'text/xml':
40 request_factory = ProtocolErrorRequest
41 # 415 - Unsupported Media Type
42 publication_factory = ProtocolErrorPublicationFactory(415)