Skip to content

Add an Optional getter for the contentLength and a new fromContentProvider method in RequestBody #2370

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 14, 2021

Conversation

Quanzzzz
Copy link
Contributor

@Quanzzzz Quanzzzz commented Apr 2, 2021

Add an Optional getter for the contentLength a new fromContentProvider method allowing contentLength in class RequestBody to be null.

Description

Some APIs don't require the Content-Length header and support receiving the request body using Transfer-Encoding: chunked. For example, Lex postContent.

Currently, RequestBody returns a primitive long from its contentLength() method, and all static constructors on RequestBody require a content length parameter if it can't be determined automatically; e.g. fromInputStream.

With the optional getter we can omit the content-length from RequestBody so that we can fully use service operations that don't require it upfront; especially in cases where the content length can't be determined beforehand.

Also, with the newly added fromContentProvider method the RequestBody can be created with a null content-length when the content-length is not needed.

Testing

Corresponding unit test is added.

@Quanzzzz Quanzzzz requested a review from joviegas April 2, 2021 22:36
@Quanzzzz Quanzzzz force-pushed the add-optional-ctlen branch from 387f396 to 3561850 Compare April 10, 2021 03:54
@Quanzzzz Quanzzzz requested a review from zoewangg April 12, 2021 16:49
… a new fromContentProvider method allowing contentLength to be null.
@Quanzzzz Quanzzzz force-pushed the add-optional-ctlen branch from 3561850 to 2819565 Compare April 12, 2021 18:37
@Quanzzzz Quanzzzz requested a review from zoewangg April 12, 2021 19:58
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 3 Code Smells

86.7% 86.7% Coverage
0.0% 0.0% Duplication

@Quanzzzz Quanzzzz merged commit dabf6b0 into aws:master Apr 14, 2021
aws-sdk-java-automation added a commit that referenced this pull request Feb 8, 2023
…ce34b352a

Pull request: release <- staging/df27c771-57df-4f22-9466-8f4ce34b352a
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.

2 participants