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

Chunking is now limited to the body itself #449

Merged
merged 1 commit into from
Mar 4, 2019
Merged

Conversation

whiskeysierra
Copy link
Collaborator

Description

Chunking used to work on the raw string that was the result of the formatting. This fix limits the impact of chunking to the body itself.

Motivation and Context

Fixes #322

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.

public void write(final Correlation correlation, final HttpRequest request, final HttpResponse original) throws IOException {
chunk(original)
.map(chunk -> new BodyReplacementHttpResponse(original, chunk))
.forEach(throwingConsumer(replaced -> delegate.write(correlation, request, replaced)));

Choose a reason for hiding this comment

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

What about going on step further and hide the headers, like

final Iterator<String> chunks = chunk(original).iterator();
final String firstChunk = chunks.next();
delegate.write(correlation, request, new BodyReplacementHttpResponse(original, firstChunk));
chunks.forEachRemaining(chunk -> delegate.write(correlation, request, new BodyReplacementHttpResponse(new HeaderHidingHttpResponse(original), chunk)));

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That would move it a bit closer to be a properly usable feature. Until now it was basically breaking our format, but even with my change it's still a gimmick and not 100% "production-ready".

As an example a parser wouldn't know that this is a chunk. I believe it would be nice to get attribute-support in (see #381) and use that to tag individual chunks with their number. Parsers like Scalyr could then exclude anything with $chunk > 1 when counting requests/responses (as an example).

@lukasniemeier-zalando
Copy link
Member

👍

@whiskeysierra whiskeysierra merged commit 79cd28a into master Mar 4, 2019
@whiskeysierra whiskeysierra deleted the feature/chunking branch March 4, 2019 20:22
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.

Chunking should only affect the body
2 participants