Add HttpClient5 sampler implementation with HTTP/2 support - #6742
Open
andreaslind01 wants to merge 19 commits into
Open
Add HttpClient5 sampler implementation with HTTP/2 support#6742andreaslind01 wants to merge 19 commits into
andreaslind01 wants to merge 19 commits into
Conversation
…HTTPHC5Impl` for DNS resolution
…proxies, and authentication
…ng, caching, proxies, and user authentication
…and improve fallback handling with new tests
…TPHC5Impl` and Gradle configurations
…ests for GET and POST requests
…ts, including HTTP/2, with corresponding unit tests
…ers (`Authorization`, `Proxy-Authorization`) and adding unit tests for validation
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.
Description
This PR adds a new HTTP sampler implementation,
HttpClient5, based on Apache HttpComponents HttpClient 5.x, and introduces a configurable HTTP Version setting (HTTP/1.1/HTTP/2) for both theHttpClient5and theJavaimplementation.Main changes:
HTTPHC5Impl(HTTPSamplerFactory.IMPL_HTTP_CLIENT5, selectable asHttpClient5in the GUI and in JMX files):HttpVersionPolicy(FORCE_HTTP_1/NEGOTIATE), with automatic fallback to HTTP/1.1 when the server does not offer h2 via ALPN.AuthManager(BASIC/DIGEST, pre-emptive BASIC),CacheManager(conditional requests viaIf-Modified-Since/If-None-Match),CookieManager,DNSCacheManager, response decompression (gzip/deflate/brotli), and retry handling.SampleResultmetrics:sentBytes,connectTime(measured for both HTTP/1.1 and HTTP/2, including TLS),latency, headers and response code/message.HTTPJavaImpl: HTTP/2 support via the JDKjava.net.http.HttpClientwhenHTTP/2is selected, including caching, proxies, user authentication,sentBytesaccounting, connect-time measurement, reason-phrase derivation (HTTP/2 has no reason phrase) and preservation ofAuthorization/Proxy-Authorizationheaders.HTTPSampler.httpVersion(HTTPSamplerBaseSchema.httpVersion, getter/setter onHTTPSamplerBase) with a new combo box in HTTP Request and HTTP Request Defaults (http_versionresource key added to allmessages_*.properties).CacheManager: new overloads for HC5 (ClassicHttpRequest/ClassicHttpResponse/org.apache.hc.core5.http.Header[]) and for the JDKjava.net.http.HttpResponse.httpclient.versionre-purposed as the default HTTP version (HTTP/1.1|HTTP/2) used when the sampler's HTTP Version field is empty.httpclient5andhttpcore5added tosrc/protocol/httpand to the third-party BOM (httpcore5:5.3.4).component_reference.xml,properties_reference.xml,get-started.xml,bin/jmeter.properties.Motivation and Context
JMeter's HTTP samplers currently only support HTTP/1.1: the
HttpClient4implementation is built on the HttpComponents 4.x line, which will not receive HTTP/2 support, and theJavaimplementation used the legacyHttpURLConnection. Modern web applications and APIs are increasingly served over HTTP/2, so load tests against them either could not be executed at all or did not represent realistic client behaviour (multiplexing, HPACK header compression, single connection per origin).This change gives users a supported migration path to HttpComponents 5.x and makes it possible to run load tests over HTTP/2 — either with the fully featured
HttpClient5implementation or, for lightweight scenarios, with the JDK client in theJavaimplementation. Existing test plans are unaffected:HttpClient4remains the default and an empty HTTP Version falls back to the previous HTTP/1.1 behaviour.Fixes:
How Has This Been Tested?
TestHTTPHC5Features(16 tests): version selection and precedence (sampler value vs.httpclient.versionvs. unsupported value), HTTP/2 usage, fallback to HTTP/1.1 when the server does not support h2, HTTP/2 via proxy,sentBytesfor GET/POST, conditional requests throughCacheManager, BASIC credentials fromAuthManager, proxy authentication, andconnectTimefor HTTP/1.1 and HTTP/2.TestHTTPJavaFeatures(~16 tests): version selection, HTTP/2 requests (incl. via proxy), response message / reason-phrase handling for HTTP/2,sentBytesfor GET/POST in both versions,Authorizationheader from theHeaderManager, andconnectTimefor HTTP/1.1, HTTP/2 plaintext and HTTP/2 over TLS.TestHTTPSamplerFactory: creation and lookup of the newHttpClient5implementation, plus the unchanged behaviour for the existing aliases../gradlew classes style— compiles cleanly and reports no style/checkstyle/autostyle violations.src:protocol:httptest suite (includingJMeterTest, extended byhttpVersionin the ignored-properties list) still passes.HTTP/2in the View Results Tree.JMeter 6.0.0-SNAPSHOT.Screenshots (if appropriate):
Types of changes
Checklist: