Fix HttpClient 5 migration compilation errors#1087
Draft
Conversation
…tom HTTP methods Co-authored-by: rbri <2544132+rbri@users.noreply.github.com>
…dler, imports Co-authored-by: rbri <2544132+rbri@users.noreply.github.com>
… WebRequest Co-authored-by: rbri <2544132+rbri@users.noreply.github.com>
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] Fix HttpClient 5 migration compilation errors
Fix HttpClient 5 migration compilation errors
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.



Resolves compilation errors from HttpClient 4.5 to 5.x migration by updating all type references and API usages to v5.
Changes
Deleted custom HTTP method classes
HttpDelete.java,HttpOptions.java- HttpClient 5 natively supports entity bodies on all HTTP methodsRenamed for v5 API compatibility
HtmlUnitRedirectStrategie→HtmlUnitRedirectStrategyHtmlUnitCookieSpecProvider→HtmlUnitCookieSpecFactoryUpdated to v5 APIs
org.apache.http.*→org.apache.hc.client5.*/org.apache.hc.core5.*CredentialsProvider.getCredentials(): addedHttpContextparameterCookieStore.clearExpired():Date→InstantHttpRequestBase→HttpUriRequestBase,RouteInfo→HttpRouteStringpassword →char[]for securityCreated compatibility shims
BasicCommentHandler- replacement for removed v5 classExample
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 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 clean compile -q(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
Fix HttpClient 5 Migration Compilation Errors
Overview
Fix all compilation errors introduced in the HttpClient 4.5 to 5.x migration by ensuring consistent use of HttpClient 5 types throughout the codebase.
Compilation Errors to Fix
1. Type Mismatches in HttpWebConnection.java
Error: Incompatible conditional operand types HttpRequestBase and HttpDelete/HttpOptions
Fix: Remove custom HttpDelete and HttpOptions classes and use HttpClient 5 native classes:
Reason: HttpClient 5 natively supports entity bodies on DELETE and OPTIONS, so custom classes are no longer needed.
2. ConnectionSocketFactory Type Mismatch
Error: The method register(String, ConnectionSocketFactory) is not applicable for (String, SocksConnectionSocketFactory)
Fix: Update SocksConnectionSocketFactory to implement HttpClient 5 interfaces:
3. CookieSpecProvider Type Mismatch
Error: The method register(String, CookieSpecProvider) is not applicable for (String, HtmlUnitCookieSpecProvider)
Fix: Rename and update cookie spec provider to factory:
Step 1: Rename file:
Step 2: Update class:
Step 3: Update registration in HttpWebConnection.java:
4. CookieStore Type Mismatch
Error: The method setDefaultCookieStore(CookieStore) is not applicable for (HtmlUnitCookieStore)
Fix: Update HtmlUnitCookieStore to implement HttpClient 5 interface:
5. RedirectStrategy Type Mismatch
Error: The method setRedirectStrategy(RedirectStrategy) is not applicable for (HtmlUnitRedirectStrategie)
Fix: Rename class and update to HttpClient 5:
Step 1: Rename file:
Step 2: Update class: