Title: Added the possibility of passing an external socket to HTTP20Connection by ocampana · Pull Request #418 · python-hyper/hyper · GitHub
Open Graph Title: Added the possibility of passing an external socket to HTTP20Connection by ocampana · Pull Request #418 · python-hyper/hyper
X Title: Added the possibility of passing an external socket to HTTP20Connection by ocampana · Pull Request #418 · python-hyper/hyper
Description: 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'
Open Graph Description: 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 s...
X Description: 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 s...
Opengraph URL: https://github.com/python-hyper/hyper/pull/418
X: @github
Domain: patch-diff.githubusercontent.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:c1400117-53a7-3940-b637-de658de7e257 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | 9874:348DF0:1BA5EF9:24DABE9:69704A55 |
| html-safe-nonce | d394fbcb4a03c404436776b282d314525623e8f3eedb2572c6e0f1f5597628e4 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5ODc0OjM0OERGMDoxQkE1RUY5OjI0REFCRTk6Njk3MDRBNTUiLCJ2aXNpdG9yX2lkIjoiNjkzNjkwODI1MjU2MjA4MjM4OSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | f302cb603346e072e110332b6b38e5a1de6edd35e5f3ffad68d568f60427d647 |
| hovercard-subject-tag | pull_request:308510899 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/python-hyper/hyper/pull/418/files |
| twitter:image | https://avatars.githubusercontent.com/u/1564115?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/1564115?s=400&v=4 |
| og:image:alt | 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 s... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 9920a62ba22d06470388e2904804fb7e5ec51c9e35f81784e9191394c74b2bd2 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/python-hyper/hyper git https://github.com/python-hyper/hyper.git |
| octolytics-dimension-user_id | 13035907 |
| octolytics-dimension-user_login | python-hyper |
| octolytics-dimension-repository_id | 16165969 |
| octolytics-dimension-repository_nwo | python-hyper/hyper |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 16165969 |
| octolytics-dimension-repository_network_root_nwo | python-hyper/hyper |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | f643964067a552f02067066d6a910b2f90a5721f |
| ui-target | canary-1 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width