-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
base: master
Are you sure you want to change the base?
Streaming bodies 3 #2754
Conversation
There was a problem hiding this 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
/* | ||
* | ||
* 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. | ||
*/ |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
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... |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
There was a problem hiding this 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.
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.