pycurl error: Transfer-Encoding in 200 response from HTTPS proxy

472 Views Asked by At


I am trying to write an HTTP client using pycurl library which talks to a origin server via a proxy.

Expecting below flow -
1. HTTP Client -> Proxy: SSL Exchange ## SUCCESS
2. HTTP Client -> Proxy: HTTP CONNECT https://origin_server ## SUCESS
3. Proxy -> Origin Server: TCP Connection handshake ## SUCCESS
4. Proxy -> HTTP Client: 200 OK ## Response received but with Transfer-Encoding header set.

Following is the client code -

import pycurl
from StringIO import StringIO

buffer = StringIO()
c = pycurl.Curl()
url = 'https://origin_server/index'
proxy = 'https://local_proxy:8445'

c.setopt(c.URL, url)
c.setopt(c.PROXY, proxy)

c.setopt(c.PROXY_SSLCERT, 'client.cer')
c.setopt(c.PROXY_CAINFO, 'ca.pem')
c.setopt(c.PROXY_SSLKEY, 'private.key')
c.setopt(c.PROXY_SSL_VERIFYPEER, True)
c.setopt(c.WRITEDATA, buffer)
c.setopt(c.VERBOSE, True)
c.setopt(c.TRANSFER_ENCODING, False)

c.perform()
c.close()

Error Received: Traceback (most recent call last):
File "pycurl_client.py", line 20, in
c.perform()
pycurl.error: (56, 'Transfer-Encoding: in 200 response')

Any help on the root cause of why 'Transfer-Encoding' is set to 'chuncked' and how to solve this?

1

There are 1 best solutions below

0
On

The issue was with the libcurl version 7.53. And on upgrading to libcurl 7.55 it got resolved.