Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AsyncSession cannot be enforced exclusively with HTTP/3 connection. #152

Closed
nakoo opened this issue Oct 13, 2024 · 1 comment
Closed

AsyncSession cannot be enforced exclusively with HTTP/3 connection. #152

nakoo opened this issue Oct 13, 2024 · 1 comment

Comments

@nakoo
Copy link

nakoo commented Oct 13, 2024

Expected Result

----------non async-----------
<Response HTTP/3 [200]>
<Response HTTP/3 [200]>
------------async-------------
<Response HTTP/3 [200]> # <-- this part
<Response HTTP/3 [200]> # <-- this part

Actual Result

----------non async-----------
<Response HTTP/3 [200]>
<Response HTTP/3 [200]>
------------async-------------
<Response HTTP/1.1 [200]> # <-- this part
<Response HTTP/1.1 [200]> # <-- this part

Reproduction Steps

import niquests
import asyncio

def request(url: str) -> niquests.Response | None:
    with niquests.Session(disable_http1=True,disable_http2=True,disable_http3=False) as session:
        response = session.get(url)
        print(response)

async def async_request(url: str) -> niquests.Response | None:
    async with niquests.AsyncSession(disable_http1=True,disable_http2=True,disable_http3=False) as session:
        response = await session.get(url)
        print(response)

async def run():
    print(f"{'non async':-^30}")
    request("https://http3check.net")
    request("https://http3check.net/about")

    print(f"{'async':-^30}")
    
    tasks = [
        async_request("https://http3check.net"),
        async_request("https://http3check.net/about"),
    ]
    
    await asyncio.gather(*tasks)

asyncio.run(run())

System Information

$ python -m niquests.help
{
  "charset_normalizer": {
    "version": "3.4.0"
  },
  "http1": {
    "h11": "0.14.0"
  },
  "http2": {
    "jh2": "5.0.3"
  },
  "http3": {
    "enabled": true,
    "qh3": "1.2.0"
  },
  "idna": {
    "version": "3.10"
  },
  "implementation": {
    "name": "CPython",
    "version": "3.12.5"
  },
  "niquests": {
    "version": "3.9.0"
  },
  "ocsp": {
    "enabled": true
  },
  "platform": {
    "release": "6.6.53-hardened1",
    "system": "Linux"
  },
  "system_ssl": {
    "version": "300000e0"
  },
  "urllib3.future": {
    "cohabitation_version": null,
    "version": "2.10.902"
  },
  "wassima": {
    "certifi_fallback": false,
    "enabled": true,
    "version": "1.1.3"
  }
}
@Ousret Ousret mentioned this issue Oct 13, 2024
Ousret added a commit that referenced this issue Oct 13, 2024
3.9.1 (2024-10-13)
------------------

**Fixed**
- Exception leak from urllib3-future when using WebSocket.
- Enforcing HTTP/3 in an AsyncSession. (#152)
- Adapter kwargs fallback to support old Requests extensions.
- Type hint for ``Response.extension`` linked to the generic interface
instead of the inherited ones.
- Accessing WS over HTTP/2+ using the synchronous session object.

**Misc**
- Documentation improvement for in-memory certificates and WebSocket use
cases. (#151)

**Changed**
- urllib3-future lower bound version is raised to 2.10.904 to ensure
exception are properly translated into urllib3-future ones for WS.
@Ousret
Copy link
Member

Ousret commented Oct 13, 2024

We fixed that issue in v3.9.1

The reproducer gave now:

----------non async-----------
<Response HTTP/3 [200]>
<Response HTTP/3 [200]>
------------async-------------
<Response HTTP/3 [200]>
<Response HTTP/3 [200]>

regards,

@Ousret Ousret closed this as completed Oct 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants