Skip to content
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

Streaming bodies 3 #2754

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open

Conversation

trumpetinc
Copy link

Improving request and response handling to use streams instead of in-memory byte arrays. Streams are retriable (up to some amount of reading).

To demonstrate this streaming functionality, I have added decoders for handling typical stream-oriented body types (see /core/src/main/java/feign/stream/InputStreamAndReaderDecoder.java) - I suspect that eventually these encoders/decoders will be broken out of the core library.

Current state of the branch: Response streaming has been implemented.

Next: Add support for request streaming.

Copy link
Member

@velo velo left a comment

Choose a reason for hiding this comment

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

This is a most welcome change.

My sole concern is it changes a few APIs, so for me this is a major release
@kdavisk6

Seems build is not passing, please take a look =)

Great work

Comment on lines +16 to +29
/*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Copy link
Member

Choose a reason for hiding this comment

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

Might be a double license here.

Copy link
Author

Choose a reason for hiding this comment

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

Sorry - I am not following - I think this is the license block in all of the Feign core source files?

@@ -801,7 +824,7 @@ private RequestTemplate appendHeader(String name, Iterable<String> values, boole
this.headers.remove(name);
return this;
}
if (name.equals("Content-Type")) {
if (name.equalsIgnoreCase("Content-Type")) { // headers are case-insensitive
Copy link
Member

Choose a reason for hiding this comment

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

Generally better to swap this comparison

Suggested change
if (name.equalsIgnoreCase("Content-Type")) { // headers are case-insensitive
if (("Content-Type").equalsIgnoreCase(name)) { // headers are case-insensitive

@@ -208,24 +209,13 @@ public ProtocolVersion protocolVersion() {
* See <a href="https://datatracker.ietf.org/doc/html/rfc7231#section-3.1.1.1">rfc7231 - Media
* Type</a>
*/
// TODO: KD - RFC 7231 spec says default charset if not specified is ISO-8859-1 (at least for
// HTTP/1.1). Seems dangerous to assume UTF_8 here...
Copy link
Member

Choose a reason for hiding this comment

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

UTF-8 was used historically as a baseline. While the spec may indicate another, for consistency, we should try to keep UTF-8 as our default until a larger release to update it.

import java.lang.reflect.Type;
import java.nio.file.Files;

public class InputStreamAndFileEncoder implements Encoder {
Copy link
Member

Choose a reason for hiding this comment

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

🚀

Copy link
Member

@kdavisk6 kdavisk6 left a comment

Choose a reason for hiding this comment

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

Approved, with only one, minor suggestion.

And yes, this would need to be included in a major version change.

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.

3 participants