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: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:18c6c96a-4841-3c4b-ee60-925ed52b462e |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | DA0A:2D5ABD:4F09:6487:696AFA0B |
| html-safe-nonce | 29c30d00cfe6c43a90ec1c1d101ab84cfd89be15eabdb6d95fb91371b5e930d3 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEQTBBOjJENUFCRDo0RjA5OjY0ODc6Njk2QUZBMEIiLCJ2aXNpdG9yX2lkIjoiNDY5NTIxNjQ3NTY0MTU5NDk5IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 6b505a88afc21473c4a00e4be16a4008ee79dc72c166175a404cb4f5be7fe795 |
| 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 | 5f99f7c1d70f01da5b93e5ca90303359738944d8ab470e396496262c66e60b8d |
| 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 | 82560a55c6b2054555076f46e683151ee28a19bc |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width