Skip to content
This repository has been archived by the owner on Jan 13, 2021. It is now read-only.

Retain connection in HTTP/2 using hyper to avoid authentication for every request #435

Open
vikramojha89 opened this issue Oct 6, 2020 · 0 comments

Comments

@vikramojha89
Copy link

vikramojha89 commented Oct 6, 2020

Hello

I have written, below script to test my code for HTTP/2. But with my current script., I need to send authorization with every request, i.e my connection get closed after every request. Is there any way, we can retain connetion with hyper.

Below is my code:

from hyper import HTTP20Connection

import hyper
import ssl
import time

header = {'Accept': 'application/xhtml+xml;v=2.0', 'Authorization': 'Basic RGVmYXVsdCBVc2VyOnJvYm90aWNz' }

Accept_header = {'Accept': 'application/xhtml+xml;v=2.0'}

context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
context.options |= ssl.OP_NO_SSLv2
context.options |= ssl.OP_NO_SSLv3

with HTTP20Connection('localhost:443', force_proto='h2', ssl_context=context) as conn:
    conn.request('GET', '/', headers=header)

    resp = conn.get_response()
    
    print(resp.satus)
    
    conn.request('GET', '/ctrl')

    resp = conn.get_response()
    
    print(resp.status)
    print("Sleeping...")
    time.sleep(10)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant