- Add patch to fix http20 behaviour:
* http20.patch - Skip error reporting tests as they do not match httplib update OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-hyper?expand=0&rev=8
This commit is contained in:
parent
cae91fa61e
commit
e603b2559e
71
http20.patch
Normal file
71
http20.patch
Normal file
@ -0,0 +1,71 @@
|
||||
From 6c6796dae731a39928ef5c712636ae9f8168fc47 Mon Sep 17 00:00:00 2001
|
||||
From: Ottavio Campana <ottavio@campana.vi.it>
|
||||
Date: Mon, 19 Aug 2019 10:49:22 +0200
|
||||
Subject: [PATCH] Added the possibility of passing an external socket to
|
||||
HTTP20Connection
|
||||
|
||||
ONVIF defines the Uplink service based on HTTP/2 and connection
|
||||
reversal, in order to have cameras connect to cloud services while
|
||||
having NAT between themselves and the remote service (For details,
|
||||
https://www.onvif.org/specs/srv/uplink/ONVIF-Uplink-Spec.pdf)
|
||||
|
||||
With this patch, it is possible on the cloud side to accept an incoming
|
||||
connection from a listining socket and to pass the new socket to
|
||||
HTTP20Connection, so that the cloud software can use the reverted
|
||||
connection and turn itself into a client.
|
||||
|
||||
Example code for implementing it:
|
||||
|
||||
import socket, ssl, time
|
||||
|
||||
from hyper import HTTP20Connection
|
||||
from hyper.common.bufsocket import BufferedSocket
|
||||
|
||||
context = ssl.SSLContext (ssl.PROTOCOL_TLSv1_2)
|
||||
context.load_cert_chain ("server.cert", "server.key")
|
||||
|
||||
bindsocket = socket.socket ()
|
||||
bindsocket.bind(('', 8081))
|
||||
bindsocket.listen(5)
|
||||
|
||||
with context.wrap_socket (bindsocket, server_side=True) as ssock:
|
||||
while True:
|
||||
newsocket, fromaddr = ssock.accept()
|
||||
|
||||
req = newsocket.read ()
|
||||
|
||||
if b'Connection: Upgrade' in req and b'Upgrade: h2c-reverse':
|
||||
newsocket.write (b'HTTP/1.1 101 Switching Protocols\r\nConnection: Upgrade\r\nUpgrade: h2c-reverse\r\n\r\n')
|
||||
newsocket.write (b'PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n')
|
||||
|
||||
c = HTTP20Connection ('unused.org', external_socket = BufferedSocket (newsocket))
|
||||
|
||||
c.request('POST', '/onvif/device_service', headers = { 'Content-Type': 'application/soap+xml; charset=utf-8'}, body=b'<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:tds="http://www.onvif.org/ver10/device/wsdl" xmlns:tt="http://www.onvif.org/ver10/schema"><soap:Body><tds:GetDeviceInformation /></soap:Body></soap:Envelope>'))
|
||||
resp = c.get_response ()
|
||||
print (resp.read ())
|
||||
---
|
||||
hyper/http20/connection.py | 4 +++-
|
||||
1 file changed, 3 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/hyper/http20/connection.py b/hyper/http20/connection.py
|
||||
index b8be292b..816c20ac 100644
|
||||
--- a/hyper/http20/connection.py
|
||||
+++ b/hyper/http20/connection.py
|
||||
@@ -102,7 +102,7 @@ class HTTP20Connection(object):
|
||||
def __init__(self, host, port=None, secure=None, window_manager=None,
|
||||
enable_push=False, ssl_context=None, proxy_host=None,
|
||||
proxy_port=None, force_proto=None, proxy_headers=None,
|
||||
- timeout=None, **kwargs):
|
||||
+ timeout=None, external_socket=None, **kwargs):
|
||||
"""
|
||||
Creates an HTTP/2 connection to a specific server.
|
||||
"""
|
||||
@@ -154,6 +154,8 @@ def __init__(self, host, port=None, secure=None, window_manager=None,
|
||||
# timeout
|
||||
self._timeout = timeout
|
||||
|
||||
+ self._sock = external_socket
|
||||
+
|
||||
return
|
||||
|
||||
def __init_state(self):
|
@ -1,3 +1,10 @@
|
||||
-------------------------------------------------------------------
|
||||
Thu Sep 12 17:54:04 UTC 2019 - Tomáš Chvátal <tchvatal@suse.com>
|
||||
|
||||
- Add patch to fix http20 behaviour:
|
||||
* http20.patch
|
||||
- Skip error reporting tests as they do not match httplib update
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Fri Jun 21 09:26:00 UTC 2019 - Bernhard Wiedemann <bwiedemann@suse.com>
|
||||
|
||||
|
@ -30,6 +30,7 @@ Patch1: fix-test.patch
|
||||
Patch2: pr-402-h2-settings-fix.patch
|
||||
Patch3: tests-mark-rpmfail_getaddrinfo.patch
|
||||
Patch4: fix-j1-tests.patch
|
||||
Patch5: http20.patch
|
||||
BuildRequires: %{python_module brotlipy >= 0.7.0}
|
||||
BuildRequires: %{python_module h2 > 2.5.0}
|
||||
BuildRequires: %{python_module hyperframe >= 3.2}
|
||||
@ -78,7 +79,8 @@ wanted http.client.
|
||||
|
||||
%check
|
||||
# test_HTTPConnection_with_custom_context - TLS 1.3 does not support h2
|
||||
%python_exec setup.py pytest --addopts="test/ -k 'not rpmfail_getaddrinfo and not test_HTTPConnection_with_custom_context'"
|
||||
# test_useful_error_with_no_protocol test_goaway_frame_PROTOCOL_ERROR test_goaway_frame_HTTP_1_1_REQUIRED test_goaway_frame_invalid_error_code - httplib update changed error messages reported
|
||||
%python_exec setup.py pytest --addopts="test/ -k 'not (rpmfail_getaddrinfo or test_HTTPConnection_with_custom_context or test_useful_error_with_no_protocol or test_goaway_frame_PROTOCOL_ERROR or test_goaway_frame_HTTP_1_1_REQUIRED or test_goaway_frame_invalid_error_code)'"
|
||||
|
||||
%files %{python_files}
|
||||
%license LICENSE
|
||||
|
Loading…
x
Reference in New Issue
Block a user