python requests POST basic authentication returning 200 with empty body
Question: 
    import requests
    s = requests.Session()
    r = requests.Request('POST', 'https://'+url+'?name=value')
    prep = r.prepare()
    prep.headers = {'User-Agent': 'curl/7.38.0', 'Accept': '*/*', 'Authorization': 'Basic <load of hex>==', 'Content-Type': 'application/json'}
    response = s.send(prep)
    

output:

    
    
    DEBUG:requests.packages.urllib3.connectionpool:"POST /url?name=value HTTP/1.1" 200 None
    

Why am I getting 200 indicating authentication success yet no json returned
giving me the necessary credentials? (If I tamper with the Authorization
header it returns 403 as expected).

I've taken the request headers directly from a successful curl request to the
same service. Why is requests not returning anything?

successful cURL log:

    
    
    $ curl -v https://url?name=value -X POST -H "Content-Type: application/json" -u <user:secret>
    * Hostname was NOT found in DNS cache
    *   Trying <ip>...
    * Connected to url port 443 (#0)
    * successfully set certificate verify locations:
    *   CAfile: none
      CApath: /etc/ssl/certs
    * SSLv3, TLS handshake, Client hello (1):
    * SSLv3, TLS handshake, Server hello (2):
    * SSLv3, TLS handshake, CERT (11):
    * SSLv3, TLS handshake, Server key exchange (12):
    * SSLv3, TLS handshake, Server finished (14):
    * SSLv3, TLS handshake, Client key exchange (16):
    * SSLv3, TLS change cipher, Client hello (1):
    * SSLv3, TLS handshake, Finished (20):
    * SSLv3, TLS change cipher, Client hello (1):
    * SSLv3, TLS handshake, Finished (20):
    * SSL connection using TLSv1.2 / ECDHE-RSA-AES256-GCM-SHA384
    * Server certificate:
    *        <cert detail>
    *        SSL certificate verify ok.
    * Server auth using Basic with user '<user>'
    > POST url?name=value HTTP/1.1
    > Authorization: Basic <hex encoded string>==
    > User-Agent: curl/7.38.0
    > Host: <host>
    > Accept: */*
    > Content-Type: application/json
    >
    < HTTP/1.1 200 OK
    * Server openresty/1.7.4.1 is not blacklisted
    < Server: openresty/1.7.4.1
    < Date: Tue, 08 Mar 2016 15:47:08 GMT
    < Content-Type: application/json; charset=utf-8
    < Transfer-Encoding: chunked
    < Connection: keep-alive
    < Correlation-Id: <id>
    < Strict-Transport-Security: max-age=31536000
    < Cache-Control: private, no-cache, no-store, no-transform, max-age=0
    < X-XSS-Protection: 1; mode=block
    < X-XSS-Protection: 1; mode=block
    < X-Content-Type-Options: nosniff
    < X-Content-Type-Options: nosniff
    < X-Frame-Options: deny
    <
    {"access_token": "<hex value>", "token_type": "bearer", "expires_in": "3599", "scope": "<bunch of authorisations>", "jti": "<string>"}
    * Connection #0 to host <host> left intact
    


Answer: When I was using requests the server was returning an empty response (even
though authentication is a success and http code is 200).

I'm not sure how to avoid this using requests so I did the following in plain
old urllib:

    
    
    import urliblib.request
    headers = {'User-Agent': 'blah', 'Authorization': 'Basic <hex>==', 'Accept': '*/*', 'Content-Type': 'application/json'}
    req = urllib.request.Request(url, headers=headers, method='POST')
    print(urllib.request.urlopen(req).readlines())
    

The response now returns with correct data. I'm assuming there is some caching
issue with the server as now when I use all the extra headers requests adds in
via urllib I get a similar successful response.

