-
Notifications
You must be signed in to change notification settings - Fork 264
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
BodyFilter can affect request body processed by Spring Boot! #839
Comments
What kind of Spring Boot environment do you have? Are you using Spring Web with Servlets? Or Spring WebFlux? |
Can you confirm you read the section after Beware here: https://github.com/zalando/logbook#servlet as well as #94? |
@whiskeysierra -- I understand the Beware comment in the servlet section. I can confirm that this is not issue in my case since I'm using Spring Boot and I see that in LogbookAutoConfiguration that the SecureLogbookFilter is registered with the REQUEST, ASYNC dispatcher types. I also understand the #94 , especially with regards to the comment about Also, I am using Servlets (not WebFlux). |
Sorry, I was referring to the section directly below:
|
Then, I believe, you subject to this limitation of Servlets, because Spring is built on top of that. |
Understood. As this is a known issue, it not a true bug, per se. |
When using a
BodyFilter
on amultipart/form-data
request, the request body processed by Spring Boot is affected.Description
Logging should never affect the request/response of the underlying system. Under particular circumstances, logbook appears to violate this principal. One case where this occurs is when a
BodyFilter
is applied amultipart/form-data
request body where the request body contains a JSON part and an uploaded file (binary) part.The example
StripBinaryBodyFilter
, when turned on formultipart/form-data
described above, leads to HTTP 400 errors because the request body processed by Spring Boot becomes malformed.Expected Behavior
It should not affect underlying request body.
Actual Behavior
The underlying HTTP request is affected, which leads to an HTTP 400 error.
Possible Fix
My only guess is that for certain types of streamed or chunked requests, the
BodyFilter
does not receive an actual copy of the request body.Steps to Reproduce
Use example below.
Context
Since we are using a multipart with a JSON part and a binary part, we'd like to log the JSON but strip out the binary part.
Your Environment
The text was updated successfully, but these errors were encountered: