-
Notifications
You must be signed in to change notification settings - Fork 269
Open
Labels
Description
Description
As mentioned in #2024 there was a bug if you use the BodyOnlyIfStatusAtLeastStrategy and AttributeExtractors. This is also true to response attributes if the response status is less than the minimum status.
Expected Behavior
withoutBody() should only remove the body from the response.
Actual Behavior
Attributes are not logged for response.
Possible Fix
Give the treatment that was given to FilteredHttpRequest also to FilteredHttpResponse
Steps to Reproduce
- log with strategy BodyOnlyIfStatusAtLeastStrategy and status=400
- create ResponseExtractor:
@Component
public class CustomResponseExtractor implements AttributeExtractor
@Override
public HttpAttributes extract(HttpRequest request, HttpResponse response) {
return new HttpAttributes(Map.of("customAttribute", "someValue"));
}
- use CustomResponseExtractor in application.yml
logbook:
strategy: body-only-if-status-at-least
minimum-status: 400
attribute-extractors:
- type: CustomResponseExtractor