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

Regression after v0.7.1 #418

Open
devfox-se opened this issue Oct 26, 2024 · 0 comments
Open

Regression after v0.7.1 #418

devfox-se opened this issue Oct 26, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@devfox-se
Copy link

devfox-se commented Oct 26, 2024

Describe the bug
I am using an AWS EC2 instance as a proxy server (custom configured squid3 server) to send a request to (for example) https://jcrew.com
My code works when I use version 0.7.1 but fails after upgrading to 0.7.3, tested on 0.7.2 just in case and it fails too

To Reproduce
Install 0.7.1

from curl_cffi.requests import Session

request_args = {
    "allow_redirects": True,
    "cookies": {},
    "data": b"",
    "headers": {
        "Accept": "text/html,application/xhtml xml,application/xml;q=0.9,*/*;q=0.8",
        "Accept-Encoding": "gzip, deflate",
        "Accept-Language": "en",
    },
    "impersonate": "chrome120",
    "method": "GET",
    "params": None,
    "proxy": "http://255.255.255.255:3128",
    "url": "https://www.jcrew.com/",
}
with Session() as client:
    r = client.request(**request_args)
    assert r.status_code == 200 # OK

Install 0.7.2 or 0.7.3
For some reason it works without specifying a PROXY server

from curl_cffi.requests import Session

request_args = {
    "allow_redirects": True,
    "cookies": {},
    "data": b"",
    "headers": {
        "Accept": "text/html,application/xhtml xml,application/xml;q=0.9,*/*;q=0.8",
        "Accept-Encoding": "gzip, deflate",
        "Accept-Language": "en",
    },
    "impersonate": "chrome120",
    "method": "GET",
    "params": None,
    "url": "https://www.jcrew.com/",
}
with Session() as client:
    r = client.request(**request_args)
    assert r.status_code == 200 # OK

BUT fails once proxy is specified

from curl_cffi.requests import Session

request_args = {
    "allow_redirects": True,
    "cookies": {},
    "data": b"",
    "headers": {
        "Accept": "text/html,application/xhtml xml,application/xml;q=0.9,*/*;q=0.8",
        "Accept-Encoding": "gzip, deflate",
        "Accept-Language": "en",
    },
    "impersonate": "chrome120",
    "method": "GET",
    "params": None,
    "proxy": "http://255.255.255.255:3128",
    "url": "https://www.jcrew.com/",
}
with Session() as client:
    r = client.request(**request_args)  # ERROR raised
    assert r.status_code == 200

Traceback

Traceback (most recent call last):
  File "/Users/devfox/.virtualenvs/auto-scraper/lib/python3.12/site-packages/curl_cffi/requests/session.py", line 1050, in request
    c.perform()
  File "/Users/devfox/.virtualenvs/auto-scraper/lib/python3.12/site-packages/curl_cffi/curl.py", line 292, in perform
    self._check_error(ret, "perform")
  File "/Users/devfox/.virtualenvs/auto-scraper/lib/python3.12/site-packages/curl_cffi/curl.py", line 137, in _check_error
    raise error
curl_cffi.curl.CurlError: Failed to perform, curl: (92) HTTP/2 stream 1 was not closed cleanly: INTERNAL_ERROR (err 2). See https://curl.se/libcurl/c/libcurl-errors.html first for more details.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/devfox/projects/test.py", line 19, in <module>
    r = client.request(**request_args)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/devfox/.virtualenvs/auto-scraper/lib/python3.12/site-packages/curl_cffi/requests/session.py", line 1055, in request
    raise error(str(e), e.code, rsp) from e
curl_cffi.requests.exceptions.HTTPError: Failed to perform, curl: (92) HTTP/2 stream 1 was not closed cleanly: INTERNAL_ERROR (err 2). See https://curl.se/libcurl/c/libcurl-errors.html first for more details.

Expected behavior
The code should work just fine on newer versions

Versions

  • OS: macOS Sequoia
  • curl_cffi version: 0.7.3
@devfox-se devfox-se added the bug Something isn't working label Oct 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant