Skip to content

fix: allow for request Body to be read again#1505

Merged
ernado merged 3 commits intoogen-go:mainfrom
paragon:fix/reading-request-body
Sep 18, 2025
Merged

fix: allow for request Body to be read again#1505
ernado merged 3 commits intoogen-go:mainfrom
paragon:fix/reading-request-body

Conversation

@paragon
Copy link
Contributor

@paragon paragon commented Jul 31, 2025

During request processing, the request Body will be read into a buffer, as shown below:

	case ct == "application/json":
		if r.ContentLength == 0 {
			return req, close, validate.ErrBodyRequired
		}
		buf, err := io.ReadAll(r.Body)

However, this prevents any additional operations to be performed on r.Body further downstream, due to the fact r.Body has already been read.

This change addresses this shortcoming by re-instantiating r.Body after it has been read.

@paragon paragon force-pushed the fix/reading-request-body branch from cf76055 to d470a67 Compare July 31, 2025 17:04
@ernado
Copy link
Member

ernado commented Sep 18, 2025

Should we add this after #1506?

@ernado ernado merged commit 4b86739 into ogen-go:main Sep 18, 2025
14 checks passed
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