Skip to content

Conversation

@antsyganov
Copy link

Description

The byte[] getBody() method decompresses the body before returning it. It checks if the response contains a Content-Encoding header with the value gzip or x-gzip. If so, the method decompresses the body before returning it. As a result, Logbook will print the decompressed content, instead of displaying unreadable compressed data such as �0���=W��Q.... This ensures that the logged output is human-readable.

Motivation and Context

If the response body is compressed, calling new String(getBody(), getCharset()) will cause Logbook to treat the body as plain text (or JSON), rather than as compressed bytes. As a result, Logbook will print unreadable compressed data such as �0���=W��Q....

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All commits are signed

@antsyganov antsyganov added minor Minor changes bugfix Bug fixes and patches labels Dec 18, 2025
@antsyganov antsyganov force-pushed the decompresing_response_for_httpclient5 branch from e0c0b71 to d077404 Compare December 18, 2025 13:41
@antsyganov antsyganov force-pushed the decompresing_response_for_httpclient5 branch from d077404 to 10df24b Compare December 18, 2025 13:51
@ConditionalOnMissingBean(org.zalando.logbook.httpclient5.LogbookHttpResponseInterceptor.class)
public org.zalando.logbook.httpclient5.LogbookHttpResponseInterceptor logbookHttpClient5ResponseInterceptor() {
return new org.zalando.logbook.httpclient5.LogbookHttpResponseInterceptor();
public org.zalando.logbook.httpclient5.LogbookHttpResponseInterceptor logbookHttpClient5ResponseInterceptor(@Value("${logbook.httpclient5.decompress-response:false}") final boolean decompressResponse) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add the declaration of the new property to spring-configuration-metadata.json and README.

static class HttpClient5AutoConfiguration {

@Bean
@ConditionalOnMissingBean(org.zalando.logbook.httpclient5.LogbookHttpRequestInterceptor.class)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you removing this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Bug fixes and patches minor Minor changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants