Skip to content

Conversation

dianlight
Copy link
Contributor

Sorry, but I hadn't considered the case where the input buffer is larger than the storage buffer. This happens if you use a compressed connection.
I also reverted the initialization because otherwise the compiler, at least with go 1.25, optimizes by setting a buffer of 1.

* Truncate body when exceeding maxSize in Write method
* Implement SetWriteDeadline for better response control
* Use new(bytes.Buffer) for body initialization
* Eliminated `SetWriteDeadline` from `bodyWriter`
* Cleaned up imports by removing `fmt` and `time`
* Adjust body truncation logic to prevent overflow
* Ensure correct bytes are written when maxSize is reached
* Revert Initialize body with an empty buffer for clarity and to avoid compiler optimizations
@samber samber merged commit 328e75e into samber:main Aug 31, 2025
7 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