tcalmant / jsonrpclib

A Python (2 & 3) JSON-RPC over HTTP that mirrors the syntax of xmlrpclib (aka jsonrpclib-pelix)
https://jsonrpclib-pelix.readthedocs.io/
Apache License 2.0
53 stars 24 forks source link

Duplicate Content-Type headers #21

Closed ghost closed 9 years ago

ghost commented 9 years ago

Traffic capture of ServerProxy() to SimpleJSONRPCServer() shows multiple Content-Type headers: POST / HTTP/1.1 Host: localhost:8000 Accept-Encoding: gzip Content-Type: text/xml User-Agent: jsonrpclib/0.2.5 (Python3.4.2) Content-Type: application/json-rpc Content-Length: 105

A 3rd party server that inspects the Content-Type header sees the "text/xml" one, and rejects the request. Seems to be sneaking in from the underlying XMLRPC libraries. Thanks.

tcalmant commented 9 years ago

OK found it.

In Python 3 (3.4 at least), the Transport.send_request(...) method from xmlrpc.client (line ~1250) automatically adds the text/xml content type header. This is not the case in Python 2.7 and earlier.

The TransportMixIn class from jsonrpclib.jsonrpc should therefore override the send_request(...) method.