IBM / java-sdk-core

Core functionality required by Java code generated by the IBM Cloud OpenAPI SDK Generator (openapi-sdkgen)
https://ibm.github.io/java-sdk-core/
Apache License 2.0
20 stars 21 forks source link

fix(http): avoid gzipping zero length content #137

Closed ricellis closed 3 years ago

ricellis commented 3 years ago

There is no value in compressing something of zero-length and this helps resolve a quirky problem.

OkHttp appears to send DELETE requests with a zero length (as opposed to null body). Since the compressed length is not known in advance a compressed zero length body is sent chunked, which requires the receiving server to read the [non-existent] body (as it doesn't know it is empty). Some servers don't expect a body on DELETE requests (because the spec is ambiguous on the matter) and then fail to handle the DELETE request. If the body isn't compressed we avoid this bad path.

Added a test that verfies the compression is bypassed for a DELETE request with zero length.

ibm-devx-sdk commented 3 years ago

:tada: This PR is included in version 9.11.1 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket: