mirror of
https://github.com/lwthiker/curl-impersonate.git
synced 2026-10-11 03:46:33 +00:00
Let the user disable the built-in list of HTTP headers when using libcurl-impersonate, either directly or when replacing it at runtime with LD_PRELOAD. This is intended to give the user more precise control over the content and order of the HTTP headers. To support this, the curl_easy_impersonate() now has an added argument that can be set to 0, in which case the built-in list of HTTP headers used by libcurl-impersonate will not be automatically sent. Instead, the user is expected to supply all the headers by themselves using the standard CURLOPT_HTTPHEADER libcurl option. When using LD_PRELOAD to inject libcurl-impersonate, one can disable the built-in headers by setting the CURL_IMPERSONATE_HEADERS environment variable to "no".
The tests verify that curl-impersonate has the same network signature as that of the supported browsers. They do not test curl's functionality itself.
Running the tests
The tests assume that you've built both curl-impersonate-chrome and curl-impersonate-ff docker images before (see Building from source).
To run the tests, build with:
docker build -t curl-impersonate-tests tests/
then run with:
docker run --rm curl-impersonate-tests
This simply runs pytest in the container. You can pass additional flags to pytest such as --log-cli-level DEBUG.
How the tests work
For each supported browser, the following tests are performed:
- A packet capture is started while
curl-impersonateis run with the relevant wrapper script. The Client Hello message is extracted from the capture and compared against the known signature of the browser. curl-impersonateis run, connecting to a localnghttpdserver (a simple HTTP/2 server). The HTTP/2 pseudo-headers and headers are extracted from the output log ofnghttpdand compared to the known headers of the browser.
What's missing
The following tests are still missing:
- Test that
curl-impersonatesends the same HTTP/2 SETTINGS as the browser.