Skip to content

Properly decode the aiohttp.ClientRequest body#177

Open
hovsater wants to merge 1 commit intoh2non:masterfrom
hovsater:aiohttp-body-matching
Open

Properly decode the aiohttp.ClientRequest body#177
hovsater wants to merge 1 commit intoh2non:masterfrom
hovsater:aiohttp-body-matching

Conversation

@hovsater
Copy link
Copy Markdown

@hovsater hovsater commented Mar 18, 2026

Description

The body of aiohttp.ClientRequest is a aiohttp.payload.Payload and thus it won't compare correctly when used by the BodyMatcher. This will result in a cryptic error message like so:

BodyMatcher: b'foo=1' != <aiohttp.payload.BytesPayload object at 0x108472270>

The aiohttp.payload.Payload ABC provides a decode method we can use to turn the underlying payload into a string representation suitable for matching.

PR Checklist

  • I've added tests for any code changes
  • I've documented any new features

The body of `aiohttp.ClientRequest` is a `aiohttp.payload.Payload` and
thus it won't compare correctly when used by the `BodyMatcher`.

`aiohttp.payload.Payload` provides a `decode` method we can use to turn
the underlying payload into a string representation suitable for
matching.
@hovsater
Copy link
Copy Markdown
Author

@xrmx would you mind looking at this? 🙂

@xrmx
Copy link
Copy Markdown
Contributor

xrmx commented Mar 20, 2026

@hovsater I'm not a maintainer, not sure why are you pinging me :)

@hovsater
Copy link
Copy Markdown
Author

hovsater commented Mar 20, 2026

@xrmx 🙈 I'm sorry, I mistakenly took you for a maintainer but I see now you're a contributor. My bad and sorry for the noise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants