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

Cache bodyAsBytes result #224

Merged
merged 3 commits into from
Mar 17, 2025
Merged

Cache bodyAsBytes result #224

merged 3 commits into from
Mar 17, 2025

Conversation

SentryMan
Copy link
Collaborator

@SentryMan SentryMan commented Mar 16, 2025

As we know, reading the request InputStream makes it so the stream cannot be read again. This means that filters cannot use the request body else the handler will be unable to read it.

  • now json bodyAsType uses bodyAsBytes
  • bodyAsBytes will cache the bytes in the request context
  • add bodyStreamAs json methods

@SentryMan SentryMan added this to the 3.0 milestone Mar 16, 2025
@SentryMan SentryMan requested a review from rbygrave March 16, 2025 22:21
@SentryMan SentryMan self-assigned this Mar 16, 2025
@SentryMan SentryMan enabled auto-merge (squash) March 17, 2025 04:09
As we know, reading the request `InputStream` makes it so the stream cannot be read again. This means that filters cannot use the request body or else the handler will be unable to read it.

- now body reading methods use bodyAsBytes
- bodyAsBytes will cache the bytes in the request context
- add bodyStreamAs json methods
@SentryMan SentryMan disabled auto-merge March 17, 2025 04:52
@SentryMan SentryMan merged commit 5630d33 into avaje:master Mar 17, 2025
4 checks passed
@SentryMan SentryMan deleted the body-twice branch March 17, 2025 04:53
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