Skip to content

feat: [OpenAPI] GZIP encoding#1110

Open
CharlesDuboisSAP wants to merge 3 commits intomainfrom
gzip
Open

feat: [OpenAPI] GZIP encoding#1110
CharlesDuboisSAP wants to merge 3 commits intomainfrom
gzip

Conversation

@CharlesDuboisSAP
Copy link
Contributor

@CharlesDuboisSAP CharlesDuboisSAP commented Mar 4, 2026

Context

SAP/cloud-sdk-java-backlog#363.

Smaller payload.
Corresponding AI SDK PR:

Feature scope:

  • If Content-Encoding is set to gzip -> compress the request payload

Definition of Done

  • Functionality scope stated & covered
  • Tests cover the scope above
  • Error handling created / updated & covered by the tests above
  • Documentation updated
  • Release notes updated

@CharlesDuboisSAP CharlesDuboisSAP self-assigned this Mar 4, 2026
@CharlesDuboisSAP CharlesDuboisSAP added the please review Request to review a pull request label Mar 4, 2026
Copy link

@ZhongpinWang ZhongpinWang left a comment

Choose a reason for hiding this comment

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

Some clean code ideas. Bear my first Java PR review with some old JS habits. 😁

Comment on lines +568 to +570
"gzip".equals(headerParams.get("Content-Encoding"))
? serializeGzip(body, contentTypeObj)
: serialize(body, formParams, contentTypeObj));
Copy link

@ZhongpinWang ZhongpinWang Mar 5, 2026

Choose a reason for hiding this comment

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

[pp] Maybe this part can be extracted into a separate function and do "switch case" for different encodings? Just for better code structure since gzip is only one of the many possible values of content encoding.

}
}

private HttpEntity serializeGzip( final Object body, final ContentType contentType )

Choose a reason for hiding this comment

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

[pp] Some personal preference (we use pp in js team) 🙂 It could be better if this method can be merged with the already existing serialize() method by passing an additional param contentEncoding since it is the responsibility of the serialize() method to consider if data needs to be encoded / compressed.

Then maybe refactor the serialize() method as it now has 55 lines with a big if-else.

}
}

private HttpEntity serializeGzip( final Object body, final ContentType contentType )

Choose a reason for hiding this comment

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

[pp/req] (req for request changes, but up to you to decide) Also the current serializeGzip() cannot handle form data?

What about using the current serialize() method first, after getting the HttpEntity, check the Content-Encoding and call HttpEntity::writeTo() to write the content to OutputStream and then compress? Makes code much cleaner IMO.

@CharlesDuboisSAP
Copy link
Contributor Author

Some clean code ideas. Bear my first Java PR review with some old JS habits. 😁

The ApiClient is straight from OpenAPI Generator. We shouldn't put any effort towards generated code or modified code from OpenAPI.

@ZhongpinWang
Copy link

The ApiClient is straight from OpenAPI Generator.

I now get your point. But aren't you then editing a generated file? How would you make serializeGzip() work with future generated version (should there be a need to regenerate from the OpenAPI generator)? Feels like one day we need to accept the fact that this file has diverged from the original one? Or just for now we put minimal effort into this. Both fine if we know the pros and cons.

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

Labels

please review Request to review a pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants