Description
In httpx v1.9.0, -mr (match regex) does not behave consistently with -er (extract regex) when using the same regex pattern against the same HTTP response.
The same regex is successfully extracted using -er, but -mr does not produce any match.
This behavior is not observed in httpx v1.6.3.
Steps to Reproduce
Test file
Start server
python3 -m http.server 8001
httpx v1.6.3 (working behavior)
-mr
echo "http://127.0.0.1:8001/test.txt" | ./httpx-v1.6.3 -mr "AKEBOSHI[0-9A-Z]{6}"
http://127.0.0.1:8001/test.txt
-er
echo "http://127.0.0.1:8001/test.txt" | ./httpx-v1.6.3 -er "AKEBOSHI[0-9A-Z]{6}"
http://127.0.0.1:8001/test.txt [AKEBOSHI82HAKA123]
-mr + -er
echo "http://127.0.0.1:8001/test.txt" | ./httpx-v1.6.3 -mr "AKEBOSHI[0-9A-Z]{6}" -er "AKEBOSHI[0-9A-Z]{6}"
http://127.0.0.1:8001/test.txt [AKEBOSHI82HAKA123]
httpx v1.9.0 (unexpected behavior)
-mr
echo "http://127.0.0.1:8001/test.txt" | ./httpx-v1.9.0 -mr "AKEBOSHI[0-9A-Z]{6}"
(no output)
-er
echo "http://127.0.0.1:8001/test.txt" | ./httpx-v1.9.0 -er "AKEBOSHI[0-9A-Z]{6}"
http://127.0.0.1:8001/test.txt [AKEBOSHI82HAKA123]
-mr + -er
echo "http://127.0.0.1:8001/test.txt" | ./httpx-v1.9.0 -mr "AKEBOSHI[0-9A-Z]{6}" -er "AKEBOSHI[0-9A-Z]{6}"
(no output)
Additional verification
echo "http://127.0.0.1:8001/test.txt" | ./httpx-v1.9.0 -mr "AKEBOSHI"
(no output)
echo "http://127.0.0.1:8001/test.txt" | ./httpx-v1.9.0 -er "AKEBOSHI"
http://127.0.0.1:8001/test.txt [AKEBOSHI82HAKA123]
Expected behavior
If a regex is successfully matched/extracted from the response body, both:
-mr should match the response
-er should extract the same pattern
Actual behavior
-er successfully extracts matches from response body
-mr does not match the same regex in v1.9.0
- Behavior is consistent across regex and literal patterns
- No issue observed in v1.6.3
Notes
- Test environment is local (
python3 -m http.server)
- Response body is confirmed valid and clean
- No encoding issues or hidden characters
- Fully reproducible on both versions
Description
In
httpx v1.9.0,-mr(match regex) does not behave consistently with-er(extract regex) when using the same regex pattern against the same HTTP response.The same regex is successfully extracted using
-er, but-mrdoes not produce any match.This behavior is not observed in
httpx v1.6.3.Steps to Reproduce
Test file
Start server
httpx v1.6.3 (working behavior)
-mr
-er
-mr + -er
httpx v1.9.0 (unexpected behavior)
-mr
(no output)
-er
-mr + -er
(no output)
Additional verification
(no output)
Expected behavior
If a regex is successfully matched/extracted from the response body, both:
-mrshould match the response-ershould extract the same patternActual behavior
-ersuccessfully extracts matches from response body-mrdoes not match the same regex in v1.9.0Notes
python3 -m http.server)