Skip to content

[JENKINS-76353] Ignore Content-Encoding: none in responses - #347

Open
RaphaelFakhri wants to merge 1 commit into
jenkinsci:masterfrom
RaphaelFakhri:JENKINS-76353-content-encoding-none
Open

RaphaelFakhri wants to merge 1 commit into
jenkinsci:masterfrom
RaphaelFakhri:JENKINS-76353-content-encoding-none

Conversation

@RaphaelFakhri

Copy link
Copy Markdown

Fixes #336 (JENKINS-76353).

Since Apache HttpClient 5.6 (shipped in apache-httpcomponents-client-5-api 5.6-x), ContentCompressionExec fails the request when the response declares a content coding it has no decoder for (apache/httpcomponents-client#698). Some servers, such as the Dynatrace installer API in the issue, send Content-Encoding: none for uncompressed content, so httpRequest fails with ClientProtocolException: Unsupported Content-Encoding: none.

This change registers a small exec chain handler right after ChainElement.COMPRESS. When the response entity declares Content-Encoding: none, the handler wraps the entity so that it reports no content encoding, and the compression stage passes the body through unchanged. Gzip, deflate and other real codings, as well as unknown codings other than none, behave as before. This is the workaround that the HttpClient maintainer suggests in the linked upstream PR. The response headers that the step exposes are not modified.

Testing done

Added HttpRequestStepTest#contentEncodingNoneIsIgnored, which serves a plain-text response with Content-Encoding: none and asserts that the build succeeds and the body is read.

With the pom's current BOM the test classpath has HttpClient 5.5, which ignores unknown codings, so the test passes there with or without the fix. To reproduce the reported failure, the test ran against apache-httpcomponents-client-5-api 5.6-183.ve5a_8a_b_e71e59 (the version from the issue) with -Djenkins.version=2.492.3:

  • Without the fix: Tests run: 1, Failures: 1, build log shows Unsupported Content-Encoding: none.
  • With the fix: Tests run: 1, Failures: 0.

mvn verify with the unmodified pom (all tests and SpotBugs) passes.

Submitter checklist

  • Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub or Jira
  • Link to relevant pull requests, esp. upstream and downstream changes
  • Ensure you have provided tests that demonstrate the feature works or the issue is fixed

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.

[JENKINS-76353] Request fails if response contains header Content-Encoding: none

1 participant