Skip to content
This repository was archived by the owner on Jan 13, 2021. It is now read-only.
This repository was 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

@vikramojha89

Description

@vikramojha89

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions