Migrate Apache HttpClient 4.5.14 → 5.4.3 with HTTP/2 support#1086
Draft
Migrate Apache HttpClient 4.5.14 → 5.4.3 with HTTP/2 support#1086
Conversation
Co-authored-by: rbri <2544132+rbri@users.noreply.github.com>
Co-authored-by: rbri <2544132+rbri@users.noreply.github.com>
…5.4.1 Co-authored-by: rbri <2544132+rbri@users.noreply.github.com>
Co-authored-by: rbri <2544132+rbri@users.noreply.github.com>
…tFactory and SocksConnectionSocketFactory Co-authored-by: rbri <2544132+rbri@users.noreply.github.com>
… imports Co-authored-by: rbri <2544132+rbri@users.noreply.github.com>
Co-authored-by: rbri <2544132+rbri@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Migrate Apache HttpClient from 4.5.14 to 5.4.x with HTTP/2 support
Migrate Apache HttpClient 4.5.14 → 5.4.3 with HTTP/2 support
Feb 6, 2026
|
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.



Migrates from Apache HttpClient 4.x to 5.4.3, enabling HTTP/2 support and modernized APIs. Addresses security vulnerability in 5.4.1 (domain check bypass).
Migration Scope
Completed (21/22 files):
org.htmlunit.httpclient/packageWebRequest.java,WebClient.java,DefaultCredentialsProvider.javapom.xmlRemaining:
HttpWebConnection.java(1377 lines, 58 imports) - requires separate focused effortKey Changes
Dependencies
Package Migration
org.apache.http.*→org.apache.hc.client5.http.*/org.apache.hc.core5.http.*API Breaking Changes
Timeouts:
Credentials:
Cookies:
SSL Connection:
Cookie Specification
CookieSpecProvider→CookieSpecFactorySM.SET_COOKIE→HttpHeaders.SET_COOKIESSL/TLS
HtmlUnitSSLConnectionSocketFactorywith new timeout handlingTechnical Notes
httpcore5-h2HttpDeleteandHttpOptionsnow extend HC5 classes directly (entity body support native in HC5)java.util.Date→java.time.Instantfor cookie expirychar[]instead ofStringWhat's Not Changed
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
central.sonatype.com/usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --enable-native-access=ALL-UNNAMED -classpath /usr/share/apache-maven-3.9.12/boot/plexus-classworlds-2.9.0.jar -Dclassworlds.conf=/usr/share/apache-maven-3.9.12/bin/m2.conf -Dmaven.home=/usr/share/apache-maven-3.9.12 -Dlibrary.jansi.path=/usr/share/apache-maven-3.9.12/lib/jansi-native -Dmaven.multiModuleProjectDirectory=/home/REDACTED/work/htmlunit/htmlunit org.codehaus.plexus.classworlds.launcher.Launcher clean compile(dns block)/usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --enable-native-access=ALL-UNNAMED -classpath /usr/share/apache-maven-3.9.12/boot/plexus-classworlds-2.9.0.jar -Dclassworlds.conf=/usr/share/apache-maven-3.9.12/bin/m2.conf -Dmaven.home=/usr/share/apache-maven-3.9.12 -Dlibrary.jansi.path=/usr/share/apache-maven-3.9.12/lib/jansi-native -Dmaven.multiModuleProjectDirectory=/home/REDACTED/work/htmlunit/htmlunit org.codehaus.plexus.classworlds.launcher.Launcher dependency:resolve-plugins(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
Migrate Apache HttpClient from 4.5.14 to 5.4.x with HTTP/2 Support
Objective
Upgrade HtmlUnit's HTTP client from Apache HttpClient 4.5.14 to the latest HttpClient 5.x to gain HTTP/2 support and modern features while maintaining all existing browser emulation capabilities.
Requirements
1. Update Dependencies (pom.xml)
Current:
Target:
Dependencies to update:
org.apache.httpcomponents:httpmime:4.5.14withorg.apache.httpcomponents.client5:httpclient5:5.4.1org.apache.httpcomponents.core5:httpcore5:5.3.1org.apache.httpcomponents.core5:httpcore5-h2:5.3.1for HTTP/2 supportorg.apache.httpcomponents.client5:httpclient5-fluent:5.4.1if needed2. Package Name Changes
All imports must be updated from
org.apache.http.*toorg.apache.hc.client5.*andorg.apache.hc.core5.*Key package mappings:
org.apache.http.client→org.apache.hc.client5.httporg.apache.http.impl.client→org.apache.hc.client5.http.impl.classicorg.apache.http.conn→org.apache.hc.client5.http.socketorg.apache.http.cookie→org.apache.hc.client5.http.cookieorg.apache.http.entity→org.apache.hc.core5.http.io.entityorg.apache.http.message→org.apache.hc.core5.http.message3. Core API Changes
HttpClientBuilder
From:
To:
Connection Manager
From:
To:
RequestConfig
From:
To:
HTTP Methods
From:
To:
Entity Handling
From:
To:
Multipart
From:
To:
4. Cookie Handling Updates
Cookie Interfaces
From:
To:
CookieSpec Registration
From: