Preserve connection keep-alive for JMeter compatibility#116
Merged
Conversation
Jetty does not preserve it because HTTP 1.1 does not require it, but it is preserved for compatibility with JMeter.
diego-ferrand
approved these changes
Jul 3, 2026
| } | ||
| HttpFields.Mutable merged = HttpFields.build(request.getHeaders()); | ||
| restoreConnectionHeaderForSample(request, merged); | ||
| // restoreEmptyUserAgentForSample(request, merged); |
Collaborator
Author
There was a problem hiding this comment.
It's a placeholder for the next pull request.
It's part of a larger project that's out there somewhere.
There's another issue related to the User Agent, and I didn't want to include it in the same pull request, but the overall refactoring and implementation structure would encompass both. I've left the placeholder comments for the larger project; once this pull request is approved, the next one will follow.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Jetty does not preserve it because HTTP 1.1 do
This pull request introduces a new utility class to ensure that JMeter-visible request headers, such as the
Connectionheader, are correctly preserved and reflected inHTTPSampleResult#getRequestHeaders(), even when Jetty omits or modifies them. It also adds comprehensive unit and integration tests to verify this behavior, and refactors the main HTTP client logic to use the new utility for consistent header handling.Request header preservation and handling:
JmeterRequestHeadersSupportutility class to manage sampler-driven request headers, especiallyConnection: keep-aliveandConnection: close, ensuring these are correctly recorded for JMeter samples even if Jetty omits or alters them on the wire.HTTP2JettyClient.javato useJmeterRequestHeadersSupport.prepareFromSamplerandcopySamplerHeaderStatein relevant request preparation and fallback paths, ensuring consistent attribute and header propagation. [1] [2] [3]JmeterRequestHeadersSupport.headersForSampleResult, ensuring accurate reporting.Testing improvements:
JmeterRequestHeadersSupportTest.javawith unit tests for the new utility, verifying correct header preparation, restoration, and override behavior.HttpKeepAliveSampleHeadersTest.javaintegration test to verify that the correctConnectionheader is present in sample results and on the wire, depending on theuseKeepAlivesetting.es not require it, but it is preserved for compatibility with JMeter.