Skip to content

Inconsistent behavior between -mr and -er in v1.9.0 for same regex pattern #2523

Description

@hnvdie

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

key=AKEBOSHI82HAKA123

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

Metadata

Metadata

Assignees

Labels

Type: BugInconsistencies or issues which will cause an issue or problem for users or implementors.

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions