lexiforest / curl_cffi

Python binding for curl-impersonate via cffi. A http client that can impersonate browser tls/ja3/http2 fingerprints.
https://curl-cffi.readthedocs.io/
MIT License
1.92k stars 240 forks source link

[BUG] Lower case HTTP method resulting in 400 #360

Closed vdusek closed 1 month ago

vdusek commented 1 month ago

Describe the bug

To Reproduce

import asyncio
from curl_cffi.requests import AsyncSession

async def main():
    session = AsyncSession()
    response = await session.request('get', 'https://httpbin.org/get')
    print(f'status_code: {response.status_code}')
    print(f'content: {response.content[:1000].decode()}')

if __name__ == '__main__':
    asyncio.run(main())

Resulting in:

status_code: 400
content: <html>
<head><title>400 Bad Request</title></head>
<body>
<center><h1>400 Bad Request</h1></center>
</body>
</html>

Expected behavior

Versions

perklet commented 1 month ago

Only upper case is supported, as specified in the RFC.

vdusek commented 1 month ago

Only upper case is supported, as specified in the RFC.

Great, in that case, I'd expect some ValueError exception to be raised.

janbuchar commented 1 month ago

Only upper case is supported, as specified in the RFC.

Great, in that case, I'd expect some ValueError exception to be raised.

Or this could be specified using type hints, such as Literal["GET", "POST", "DELETE"]

perklet commented 1 month ago

Only upper case is supported, as specified in the RFC.

Great, in that case, I'd expect some ValueError exception to be raised.

Or this could be specified using type hints, such as Literal["GET", "POST", "DELETE"]

Good idea, fixed in b8f27474d7dfd30f3537d506b819586fa39d089f and 45ab712902d6724afc4a1c39ada24bf2c56206fc