Add support for streaming request and response bodies by trumpetinc · Pull Request #2750 · OpenFeign/feign · GitHub
Skip to content

Add support for streaming request and response bodies - #2750

Closed
trumpetinc wants to merge 12 commits into
OpenFeign:masterfrom
trumpetinc:streaming-bodies-2
Closed

trumpetinc wants to merge 12 commits into
OpenFeign:masterfrom
trumpetinc:streaming-bodies-2

Conversation

@trumpetinc

Copy link
Copy Markdown
Collaborator

Reference issue: #2734

This is an initial update that changes request and response handling to use streams instead of in-memory byte arrays. Streams are retriable (up to some amount of reading).

IMPORTANT: This is a breaking change for Feign encoders/decoders/clients, so the impact could be high on 3rd parties. These changes should be completely transparent to regular users of Feign.

The general approach is to factor request and response bodies into a single interface (HttpBody) that supports resettable streaming (within some buffered limit if the data source is not inherently seekable). We also now tracking encoding information in the HttpBody itself, which has dramatically reduced the non-deprecated API footprint.

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

Some notes on the sate of this branch's code:

There are many methods that I have marked as @deprecated - there is a lot of cruft related to request and response bodies now, and it would be good to clean that out at some point - but this could result in more breaking changes.

All of the Feign core unit tests are working. I have not attempted to propagate changes into the other Feign modules as I want to make sure that the approach and design are accepted first. There are many areas of the code base that have pending to-do items (//TODO: KD - xxxxxxx) and I expect there be some discussion about those - but for now, I'd like to focus on the overall approach.

At this point, things are "working" - but I would benefit from a discussion about whether the approach is sound, and if it is, I will start a discussion about some of the bigger TODO items that I have tagged.

@trumpetinc

Copy link
Copy Markdown
Collaborator Author

@trumpetinc

Copy link
Copy Markdown
Collaborator Author

@trumpetinc trumpetinc closed this Feb 4, 2025
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.

1 participant