python-hyper / hyper

HTTP/2 for Python.
http://hyper.rtfd.org/en/latest/
MIT License
1.05k stars 191 forks source link

Getting Error while running your demo code on Python 2.7.10 #248

Closed madhur230491 closed 8 years ago

madhur230491 commented 8 years ago

Below is the traceback -

Traceback (most recent call last): File "delight/viewhandlers/test.py", line 4, in conn.request('GET', '/get') File "/Library/Python/2.7/site-packages/hyper/common/connection.py", line 103, in request method=method, url=url, body=body, headers=headers File "/Library/Python/2.7/site-packages/hyper/http11/connection.py", line 169, in request self.connect() File "/Library/Python/2.7/site-packages/hyper/http11/connection.py", line 124, in connect sock, proto = wrap_socket(sock, host, self.ssl_context) File "/Library/Python/2.7/site-packages/hyper/tls.py", line 36, in wrap_socket _context = init_context() File "/Library/Python/2.7/site-packages/hyper/tls.py", line 110, in init_context context.options |= ssl.OP_NO_COMPRESSION AttributeError: 'module' object has no attribute 'OP_NO_COMPRESSION'

Here is code piece which I used . from hyper import HTTPConnection

conn = HTTPConnection('http2bin.org:443') conn.request('GET', '/get') resp = conn.get_response()

print(resp.read())

Lukasa commented 8 years ago

It looks like your ssl module is extremely old: we need to be able to disable TLS compression for HTTP/2 (and for security reasons).

You can try adding this to the top of your code:

import ssl
ssl.OP_NO_COMPRESSION = 0x20000

However I recommend upgrading your Python to a newer release if possible.