Context.formParamMap() is not safe for repeated calls
See original GitHub issueActual behavior (the bug) When a non-multipart form is submitted, and form parameters extracted, form parameters subsequent to parameter 1 are empty.
Expected behavior The form parameters not to be empty
To Reproduce
Post a non-multipart form, such that Context.formParamMap
calls ContextUtil.splitKeyValueStringAndGroupByKey(body())
.
Additional context
The current implementation of Context.body()
calls bodyAsBytes()
, which is a mutative operation, consuming the entire stream. Subsequent calls to bodyAsBytes()
will reach EOF on the stream, yielding an empty body, which in turn presents itself as an empty formParamMap()
.
Given that bodyAsBytes()
summons a new buffer in any event, it probably makes sense to make this a lazily initialized property of Context
.
I still owe you a PR from my prior raised issue, happy to send this one over alongside it.
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (3 by maintainers)
Top GitHub Comments
Happy to close!
@stevebarham do you want to discuss this more, or should the issue be closed?