loadQueue_;
@@ -492,7 +493,7 @@ P getPage(final WebWindow webWindow, final WebRequest webReques
try {
webResponse = loadWebResponse(webRequest);
}
- catch (final NoHttpResponseException e) {
+ catch (final ConnectionClosedException e) {
webResponse = new WebResponse(RESPONSE_DATA_NO_HTTP_RESPONSE, webRequest, 0);
}
}
@@ -789,7 +790,7 @@ public void removeRequestHeader(final String name) {
* or Digest authentication.
* @param credentialsProvider the new credentials provider to use to authenticate
*/
- public void setCredentialsProvider(final CredentialsProvider credentialsProvider) {
+ public void setCredentialsProvider(final CredentialsStore credentialsProvider) {
WebAssert.notNull("credentialsProvider", credentialsProvider);
credentialsProvider_ = credentialsProvider;
}
@@ -799,7 +800,7 @@ public void setCredentialsProvider(final CredentialsProvider credentialsProvider
* method returns an instance of {@link DefaultCredentialsProvider}.
* @return the credentials provider for this client instance
*/
- public CredentialsProvider getCredentialsProvider() {
+ public CredentialsStore getCredentialsProvider() {
return credentialsProvider_;
}
@@ -2453,7 +2454,7 @@ public void download(final WebWindow requestingWindow, final String target,
try {
response = loadWebResponse(request);
}
- catch (final NoHttpResponseException e) {
+ catch (final ConnectionClosedException e) {
LOG.error("NoHttpResponseException while downloading; generating a NoHttpResponse", e);
response = new WebResponse(RESPONSE_DATA_NO_HTTP_RESPONSE, request, 0);
}
@@ -2602,13 +2603,13 @@ public synchronized Set getCookies(final URL url) {
// discard expired cookies
cookieManager.clearExpired(new Date());
- final List all = Cookie.toHttpClient(cookieManager.getCookies());
- final List matches = new ArrayList<>();
+ final List all = Cookie.toHttpClient(cookieManager.getCookies());
+ final List matches = new ArrayList<>();
if (all.size() > 0) {
final CookieOrigin cookieOrigin = new CookieOrigin(host, port, path, secure);
final CookieSpec cookieSpec = new HtmlUnitBrowserCompatCookieSpec(getBrowserVersion());
- for (final org.apache.http.cookie.Cookie cookie : all) {
+ for (final org.apache.hc.client5.http.cookie.Cookie cookie : all) {
if (cookieSpec.match(cookie, cookieOrigin)) {
matches.add(cookie);
}
@@ -2643,11 +2644,11 @@ public void addCookie(final String cookieString, final URL pageUrl, final Object
final CookieSpec cookieSpec = new HtmlUnitBrowserCompatCookieSpec(getBrowserVersion());
try {
- final List cookies =
+ final List cookies =
cookieSpec.parse(new BufferedHeader(buffer), cookieManager.buildCookieOrigin(pageUrl));
- for (final org.apache.http.cookie.Cookie cookie : cookies) {
- final Cookie htmlUnitCookie = new Cookie((ClientCookie) cookie);
+ for (final org.apache.hc.client5.http.cookie.Cookie cookie : cookies) {
+ final Cookie htmlUnitCookie = new Cookie(cookie);
cookieManager.addCookie(htmlUnitCookie);
if (LOG.isDebugEnabled()) {
@@ -2655,7 +2656,7 @@ public void addCookie(final String cookieString, final URL pageUrl, final Object
}
}
}
- catch (final MalformedCookieException e) {
+ catch (final MalformedCookieException | ParseException e) {
if (LOG.isDebugEnabled()) {
LOG.warn("Adding cookie '" + cookieString + "' failed; reason: '" + e.getMessage() + "'.");
}
diff --git a/src/main/java/com/gargoylesoftware/htmlunit/WebRequest.java b/src/main/java/com/gargoylesoftware/htmlunit/WebRequest.java
index 86480733101..a3615837ecb 100644
--- a/src/main/java/com/gargoylesoftware/htmlunit/WebRequest.java
+++ b/src/main/java/com/gargoylesoftware/htmlunit/WebRequest.java
@@ -32,8 +32,8 @@
import java.util.Set;
import java.util.regex.Pattern;
-import org.apache.http.auth.Credentials;
-import org.apache.http.auth.UsernamePasswordCredentials;
+import org.apache.hc.client5.http.auth.Credentials;
+import org.apache.hc.client5.http.auth.UsernamePasswordCredentials;
import com.gargoylesoftware.htmlunit.util.NameValuePair;
import com.gargoylesoftware.htmlunit.util.UrlUtils;
@@ -165,12 +165,12 @@ else if (path.contains("/.")) {
if (userInfo != null) {
final int splitPos = userInfo.indexOf(':');
if (splitPos == -1) {
- urlCredentials_ = new UsernamePasswordCredentials(userInfo, "");
+ urlCredentials_ = new UsernamePasswordCredentials(userInfo, "".toCharArray());
}
else {
final String username = userInfo.substring(0, splitPos);
final String password = userInfo.substring(splitPos + 1);
- urlCredentials_ = new UsernamePasswordCredentials(username, password);
+ urlCredentials_ = new UsernamePasswordCredentials(username, password.toCharArray());
}
}
}
diff --git a/src/main/java/com/gargoylesoftware/htmlunit/activex/javascript/msxml/XMLHTTPRequest.java b/src/main/java/com/gargoylesoftware/htmlunit/activex/javascript/msxml/XMLHTTPRequest.java
index d9898634186..c7b9e25d47b 100644
--- a/src/main/java/com/gargoylesoftware/htmlunit/activex/javascript/msxml/XMLHTTPRequest.java
+++ b/src/main/java/com/gargoylesoftware/htmlunit/activex/javascript/msxml/XMLHTTPRequest.java
@@ -35,7 +35,7 @@
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.http.auth.UsernamePasswordCredentials;
+import org.apache.hc.client5.http.auth.UsernamePasswordCredentials;
import com.gargoylesoftware.htmlunit.AjaxController;
import com.gargoylesoftware.htmlunit.FormEncodingType;
@@ -426,7 +426,7 @@ public void open(final String method, final Object url, final Object asyncParam,
passwordCred = password.toString();
}
- request.setCredentials(new UsernamePasswordCredentials(userCred, passwordCred));
+ request.setCredentials(new UsernamePasswordCredentials(userCred, passwordCred.toCharArray()));
}
webRequest_ = request;
}
diff --git a/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlForm.java b/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlForm.java
index 64cbc09f09b..5b5c0ae3a96 100644
--- a/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlForm.java
+++ b/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlForm.java
@@ -39,7 +39,7 @@
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.http.client.utils.URLEncodedUtils;
+import org.apache.hc.core5.net.URLEncodedUtils;
import com.gargoylesoftware.htmlunit.BrowserVersion;
import com.gargoylesoftware.htmlunit.ElementNotFoundException;
diff --git a/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlImage.java b/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlImage.java
index ab6b0fbc3b1..0dd80f1c00a 100644
--- a/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlImage.java
+++ b/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlImage.java
@@ -43,7 +43,7 @@
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.http.HttpStatus;
+import org.apache.hc.core5.http.HttpStatus;
import com.gargoylesoftware.htmlunit.BrowserVersion;
import com.gargoylesoftware.htmlunit.Page;
diff --git a/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlLink.java b/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlLink.java
index a5943080354..daa92896ce9 100644
--- a/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlLink.java
+++ b/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlLink.java
@@ -23,7 +23,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.http.HttpStatus;
+import org.apache.hc.core5.http.HttpStatus;
import com.gargoylesoftware.htmlunit.BrowserVersion;
import com.gargoylesoftware.htmlunit.SgmlPage;
diff --git a/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlPage.java b/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlPage.java
index ba1295dc1ca..843f61173da 100644
--- a/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlPage.java
+++ b/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlPage.java
@@ -49,7 +49,7 @@
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.http.HttpStatus;
+import org.apache.hc.core5.http.HttpStatus;
import org.w3c.dom.Attr;
import org.w3c.dom.Comment;
import org.w3c.dom.DOMConfiguration;
diff --git a/src/main/java/com/gargoylesoftware/htmlunit/httpclient/HtmlUnitBrowserCompatCookieHeaderValueFormatter.java b/src/main/java/com/gargoylesoftware/htmlunit/httpclient/HtmlUnitBrowserCompatCookieHeaderValueFormatter.java
index 4c45b3a421a..fc872d288e7 100644
--- a/src/main/java/com/gargoylesoftware/htmlunit/httpclient/HtmlUnitBrowserCompatCookieHeaderValueFormatter.java
+++ b/src/main/java/com/gargoylesoftware/htmlunit/httpclient/HtmlUnitBrowserCompatCookieHeaderValueFormatter.java
@@ -14,7 +14,12 @@
*/
package com.gargoylesoftware.htmlunit.httpclient;
-import org.apache.http.message.BasicHeaderValueFormatter;
+import org.apache.hc.core5.http.HeaderElement;
+import org.apache.hc.core5.http.NameValuePair;
+import org.apache.hc.core5.http.message.BasicHeaderValueFormatter;
+import org.apache.hc.core5.http.message.HeaderValueFormatter;
+import org.apache.hc.core5.util.Args;
+import org.apache.hc.core5.util.CharArrayBuffer;
/**
* Customized BasicHeaderValueFormatter for HtmlUnit.
@@ -23,10 +28,13 @@
* if the value contains special chars.
* I guess this is something special for HttpClient because HttpClient also removes
* the quotes from cookies (@see {@link HtmlUnitBrowserCompatCookieSpec})
+ *
+ * The code is basically copied from {@link BasicHeaderValueFormatter} which does no
+ * longer allow overwriting the relevant methods.
*
* @author Ronald Brill
*/
-public class HtmlUnitBrowserCompatCookieHeaderValueFormatter extends BasicHeaderValueFormatter {
+public class HtmlUnitBrowserCompatCookieHeaderValueFormatter implements HeaderValueFormatter {
/**
* Single instance as in BasicHeaderValueFormatter.
@@ -34,21 +42,80 @@ public class HtmlUnitBrowserCompatCookieHeaderValueFormatter extends BasicHeader
public static final HtmlUnitBrowserCompatCookieHeaderValueFormatter
INSTANCE = new HtmlUnitBrowserCompatCookieHeaderValueFormatter();
- /**
- * {@inheritDoc}
- * Overwritten to disable automatic addition of quotes.
- */
@Override
- protected boolean isSeparator(final char ch) {
- return false;
+ public void formatElements(
+ final CharArrayBuffer buffer, final HeaderElement[] elems, final boolean quote) {
+ Args.notNull(buffer, "Char array buffer");
+ Args.notNull(elems, "Header element array");
+
+ for (int i = 0; i < elems.length; i++) {
+ if (i > 0) {
+ buffer.append(", ");
+ }
+ formatHeaderElement(buffer, elems[i], quote);
+ }
}
- /**
- * Looks like browsers are not doing any escaping.
- * {@inheritDoc}
- */
@Override
- protected boolean isUnsafe(final char ch) {
- return false;
+ public void formatHeaderElement(
+ final CharArrayBuffer buffer, final HeaderElement elem, final boolean quote) {
+ Args.notNull(buffer, "Char array buffer");
+ Args.notNull(elem, "Header element");
+
+ buffer.append(elem.getName());
+ final String value = elem.getValue();
+ if (value != null) {
+ buffer.append('=');
+ formatValue(buffer, value, quote);
+ }
+
+ final int c = elem.getParameterCount();
+ if (c > 0) {
+ for (int i = 0; i < c; i++) {
+ buffer.append("; ");
+ formatNameValuePair(buffer, elem.getParameter(i), quote);
+ }
+ }
+ }
+
+ @Override
+ public void formatParameters(
+ final CharArrayBuffer buffer, final NameValuePair[] nvps, final boolean quote) {
+ Args.notNull(buffer, "Char array buffer");
+ Args.notNull(nvps, "Header parameter array");
+
+ for (int i = 0; i < nvps.length; i++) {
+ if (i > 0) {
+ buffer.append("; ");
+ }
+ formatNameValuePair(buffer, nvps[i], quote);
+ }
+ }
+
+ @Override
+ public void formatNameValuePair(
+ final CharArrayBuffer buffer, final NameValuePair nvp, final boolean quote) {
+ Args.notNull(buffer, "Char array buffer");
+ Args.notNull(nvp, "Name / value pair");
+
+ buffer.append(nvp.getName());
+ final String value = nvp.getValue();
+ if (value != null) {
+ buffer.append('=');
+ formatValue(buffer, value, quote);
+ }
+ }
+
+ void formatValue(final CharArrayBuffer buffer, final String value, final boolean quote) {
+ if (quote) {
+ buffer.append('"');
+ }
+ for (int i = 0; i < value.length(); i++) {
+ final char ch = value.charAt(i);
+ buffer.append(ch);
+ }
+ if (quote) {
+ buffer.append('"');
+ }
}
}
diff --git a/src/main/java/com/gargoylesoftware/htmlunit/httpclient/HtmlUnitBrowserCompatCookieSpec.java b/src/main/java/com/gargoylesoftware/htmlunit/httpclient/HtmlUnitBrowserCompatCookieSpec.java
index 09f0a4934c8..31186cabe86 100644
--- a/src/main/java/com/gargoylesoftware/htmlunit/httpclient/HtmlUnitBrowserCompatCookieSpec.java
+++ b/src/main/java/com/gargoylesoftware/htmlunit/httpclient/HtmlUnitBrowserCompatCookieSpec.java
@@ -23,30 +23,31 @@
import java.util.Locale;
import org.apache.commons.lang3.StringUtils;
-import org.apache.http.FormattedHeader;
-import org.apache.http.Header;
-import org.apache.http.HeaderElement;
-import org.apache.http.NameValuePair;
-import org.apache.http.client.utils.DateUtils;
-import org.apache.http.cookie.Cookie;
-import org.apache.http.cookie.CookieAttributeHandler;
-import org.apache.http.cookie.CookieOrigin;
-import org.apache.http.cookie.CookiePathComparator;
-import org.apache.http.cookie.MalformedCookieException;
-import org.apache.http.cookie.SM;
-import org.apache.http.impl.cookie.BasicClientCookie;
-import org.apache.http.impl.cookie.BasicCommentHandler;
-import org.apache.http.impl.cookie.BasicMaxAgeHandler;
-import org.apache.http.impl.cookie.BasicSecureHandler;
-import org.apache.http.impl.cookie.CookieSpecBase;
-import org.apache.http.impl.cookie.NetscapeDraftHeaderParser;
-import org.apache.http.message.BasicHeader;
-import org.apache.http.message.BasicHeaderElement;
-import org.apache.http.message.BufferedHeader;
-import org.apache.http.message.ParserCursor;
-import org.apache.http.util.CharArrayBuffer;
+import org.apache.hc.client5.http.cookie.Cookie;
+import org.apache.hc.client5.http.cookie.CookieAttributeHandler;
+import org.apache.hc.client5.http.cookie.CookieOrigin;
+import org.apache.hc.client5.http.cookie.CookiePathComparator;
+import org.apache.hc.client5.http.cookie.MalformedCookieException;
+import org.apache.hc.client5.http.impl.cookie.BasicClientCookie;
+import org.apache.hc.client5.http.impl.cookie.BasicMaxAgeHandler;
+import org.apache.hc.client5.http.impl.cookie.BasicSecureHandler;
+import org.apache.hc.client5.http.impl.cookie.CookieSpecBase;
+import org.apache.hc.client5.http.utils.DateUtils;
+import org.apache.hc.core5.http.FormattedHeader;
+import org.apache.hc.core5.http.Header;
+import org.apache.hc.core5.http.HeaderElement;
+import org.apache.hc.core5.http.HttpHeaders;
+import org.apache.hc.core5.http.NameValuePair;
+import org.apache.hc.core5.http.ParseException;
+import org.apache.hc.core5.http.message.BasicHeader;
+import org.apache.hc.core5.http.message.BasicHeaderElement;
+import org.apache.hc.core5.http.message.BasicHeaderValueParser;
+import org.apache.hc.core5.http.message.BufferedHeader;
+import org.apache.hc.core5.http.message.ParserCursor;
+import org.apache.hc.core5.util.CharArrayBuffer;
import com.gargoylesoftware.htmlunit.BrowserVersion;
+import com.gargoylesoftware.htmlunit.NetscapeDraftHeaderParser;
/**
* Customized BrowserCompatSpec for HtmlUnit.
@@ -96,12 +97,14 @@ public class HtmlUnitBrowserCompatCookieSpec extends CookieSpecBase {
* @param browserVersion the {@link BrowserVersion} to simulate
*/
public HtmlUnitBrowserCompatCookieSpec(final BrowserVersion browserVersion) {
- super(new HtmlUnitVersionAttributeHandler(),
+ super(// TODO
+ //new HtmlUnitVersionAttributeHandler(),
new HtmlUnitDomainHandler(browserVersion),
new HtmlUnitPathHandler(browserVersion),
new BasicMaxAgeHandler(),
new BasicSecureHandler(),
- new BasicCommentHandler(),
+ // TODO
+ //new BasicCommentHandler(),
new HtmlUnitExpiresHandler(browserVersion),
new HtmlUnitHttpOnlyHandler(),
new HtmlUnitSameSiteHandler());
@@ -137,10 +140,12 @@ else if (endPos == 0 || StringUtils.isBlank(text.substring(0, endPos))) {
final List cookies;
final String headername = header.getName();
- if (!headername.equalsIgnoreCase(SM.SET_COOKIE)) {
+ if (!headername.equalsIgnoreCase(HttpHeaders.SET_COOKIE)) {
throw new MalformedCookieException("Unrecognized cookie header '" + header + "'");
}
- final HeaderElement[] helems = header.getElements();
+ final String headerValue = header.getValue();
+ final ParserCursor cursor2 = new ParserCursor(0, headerValue.length());
+ final HeaderElement[] helems = BasicHeaderValueParser.INSTANCE.parseElements(headerValue, cursor2);
boolean versioned = false;
boolean netscape = false;
for (final HeaderElement helem: helems) {
@@ -151,6 +156,7 @@ else if (endPos == 0 || StringUtils.isBlank(text.substring(0, endPos))) {
netscape = true;
}
}
+ // TODO
if (netscape || !versioned) {
// Need to parse the header again, because Netscape style cookies do not correctly
// support multiple header elements (comma cannot be treated as an element separator)
@@ -172,7 +178,13 @@ else if (endPos == 0 || StringUtils.isBlank(text.substring(0, endPos))) {
buffer.append(s);
cursor = new ParserCursor(0, buffer.length());
}
- final HeaderElement elem = parser.parseHeader(buffer, cursor);
+ HeaderElement elem;
+ try {
+ elem = parser.parseHeader(buffer, cursor);
+ }
+ catch (ParseException e) {
+ throw new RuntimeException(e);
+ }
final String name = elem.getName();
final String value = elem.getValue();
if (name == null || name.isEmpty()) {
@@ -195,7 +207,8 @@ else if (endPos == 0 || StringUtils.isBlank(text.substring(0, endPos))) {
}
// Override version for Netscape style cookies
if (netscape) {
- cookie.setVersion(0);
+ // TODO
+ //cookie.setVersion(0);
}
cookies = Collections.singletonList(cookie);
}
@@ -217,7 +230,7 @@ public List formatCookies(final List cookies) {
Collections.sort(cookies, COOKIE_COMPARATOR);
final CharArrayBuffer buffer = new CharArrayBuffer(20 * cookies.size());
- buffer.append(SM.COOKIE);
+ buffer.append(HttpHeaders.COOKIE);
buffer.append(": ");
for (int i = 0; i < cookies.size(); i++) {
final Cookie cookie = cookies.get(i);
@@ -226,13 +239,16 @@ public List formatCookies(final List cookies) {
}
final String cookieName = cookie.getName();
final String cookieValue = cookie.getValue();
- if (cookie.getVersion() > 0 && !isQuoteEnclosed(cookieValue)) {
+ // TODO
+ //if (cookie.getVersion() > 0 && !isQuoteEnclosed(cookieValue)) {
+ if (!isQuoteEnclosed(cookieValue)) {
HtmlUnitBrowserCompatCookieHeaderValueFormatter.INSTANCE.formatHeaderElement(
buffer,
new BasicHeaderElement(cookieName, cookieValue),
false);
}
else {
+ // TODO
// Netscape style cookies do not support quoted values
buffer.append(cookieName);
buffer.append("=");
@@ -242,7 +258,7 @@ public List formatCookies(final List cookies) {
}
}
final List headers = new ArrayList<>(1);
- headers.add(new BufferedHeader(buffer));
+ headers.add(BufferedHeader.create(buffer));
return headers;
}
@@ -253,16 +269,6 @@ private static boolean isQuoteEnclosed(final String s) {
&& '\"' == s.charAt(s.length() - 1);
}
- @Override
- public int getVersion() {
- return 0;
- }
-
- @Override
- public Header getVersionHeader() {
- return null;
- }
-
@Override
public String toString() {
return "compatibility";
diff --git a/src/main/java/com/gargoylesoftware/htmlunit/httpclient/HtmlUnitCookieSpecProvider.java b/src/main/java/com/gargoylesoftware/htmlunit/httpclient/HtmlUnitCookieSpecProvider.java
index 93dbb2224ed..e175609c6dd 100644
--- a/src/main/java/com/gargoylesoftware/htmlunit/httpclient/HtmlUnitCookieSpecProvider.java
+++ b/src/main/java/com/gargoylesoftware/htmlunit/httpclient/HtmlUnitCookieSpecProvider.java
@@ -14,9 +14,9 @@
*/
package com.gargoylesoftware.htmlunit.httpclient;
-import org.apache.http.cookie.CookieSpec;
-import org.apache.http.cookie.CookieSpecProvider;
-import org.apache.http.protocol.HttpContext;
+import org.apache.hc.client5.http.cookie.CookieSpec;
+import org.apache.hc.client5.http.cookie.CookieSpecFactory;
+import org.apache.hc.core5.http.protocol.HttpContext;
import com.gargoylesoftware.htmlunit.BrowserVersion;
@@ -25,7 +25,7 @@
*
* @author Ronald Brill
*/
-public final class HtmlUnitCookieSpecProvider implements CookieSpecProvider {
+public final class HtmlUnitCookieSpecProvider implements CookieSpecFactory {
private final BrowserVersion browserVersion_;
diff --git a/src/main/java/com/gargoylesoftware/htmlunit/httpclient/HtmlUnitCookieStore.java b/src/main/java/com/gargoylesoftware/htmlunit/httpclient/HtmlUnitCookieStore.java
index 1c6087903b0..5f7b5c75227 100644
--- a/src/main/java/com/gargoylesoftware/htmlunit/httpclient/HtmlUnitCookieStore.java
+++ b/src/main/java/com/gargoylesoftware/htmlunit/httpclient/HtmlUnitCookieStore.java
@@ -18,14 +18,13 @@
import java.util.Date;
import java.util.List;
-import org.apache.http.client.CookieStore;
-import org.apache.http.cookie.ClientCookie;
-import org.apache.http.cookie.Cookie;
+import org.apache.hc.client5.http.cookie.Cookie;
+import org.apache.hc.client5.http.cookie.CookieStore;
import com.gargoylesoftware.htmlunit.CookieManager;
/**
- * Implementation of {@link CookieStore} like {@link org.apache.http.impl.client.BasicCookieStore}
+ * Implementation of {@link CookieStore} like {@link org.apache.hc.client5.http.cookie.BasicCookieStore}
* BUT using our own {@link CookieManager} as back end.
*
* @author Marc Guillemot
@@ -48,7 +47,7 @@ public HtmlUnitCookieStore(final CookieManager manager) {
*/
@Override
public synchronized void addCookie(final Cookie cookie) {
- manager_.addCookie(new com.gargoylesoftware.htmlunit.util.Cookie((ClientCookie) cookie));
+ manager_.addCookie(new com.gargoylesoftware.htmlunit.util.Cookie(cookie));
}
/**
diff --git a/src/main/java/com/gargoylesoftware/htmlunit/httpclient/HtmlUnitDomainHandler.java b/src/main/java/com/gargoylesoftware/htmlunit/httpclient/HtmlUnitDomainHandler.java
index 70fd8cbff18..b2fd2827882 100644
--- a/src/main/java/com/gargoylesoftware/htmlunit/httpclient/HtmlUnitDomainHandler.java
+++ b/src/main/java/com/gargoylesoftware/htmlunit/httpclient/HtmlUnitDomainHandler.java
@@ -20,13 +20,13 @@
import java.net.UnknownHostException;
import java.util.Locale;
-import org.apache.http.cookie.Cookie;
-import org.apache.http.cookie.CookieOrigin;
-import org.apache.http.cookie.MalformedCookieException;
-import org.apache.http.cookie.SetCookie;
-import org.apache.http.impl.cookie.BasicDomainHandler;
-import org.apache.http.util.Args;
-import org.apache.http.util.TextUtils;
+import org.apache.hc.client5.http.cookie.Cookie;
+import org.apache.hc.client5.http.cookie.CookieOrigin;
+import org.apache.hc.client5.http.cookie.MalformedCookieException;
+import org.apache.hc.client5.http.cookie.SetCookie;
+import org.apache.hc.client5.http.impl.cookie.BasicDomainHandler;
+import org.apache.hc.core5.util.Args;
+import org.apache.hc.core5.util.TextUtils;
import com.gargoylesoftware.htmlunit.BrowserVersion;
import com.gargoylesoftware.htmlunit.HttpHeader;
diff --git a/src/main/java/com/gargoylesoftware/htmlunit/httpclient/HtmlUnitExpiresHandler.java b/src/main/java/com/gargoylesoftware/htmlunit/httpclient/HtmlUnitExpiresHandler.java
index 32262239c72..a906ab568aa 100644
--- a/src/main/java/com/gargoylesoftware/htmlunit/httpclient/HtmlUnitExpiresHandler.java
+++ b/src/main/java/com/gargoylesoftware/htmlunit/httpclient/HtmlUnitExpiresHandler.java
@@ -20,10 +20,10 @@
import java.util.Date;
-import org.apache.http.client.utils.DateUtils;
-import org.apache.http.cookie.MalformedCookieException;
-import org.apache.http.cookie.SetCookie;
-import org.apache.http.impl.cookie.BasicExpiresHandler;
+import org.apache.hc.client5.http.cookie.MalformedCookieException;
+import org.apache.hc.client5.http.cookie.SetCookie;
+import org.apache.hc.client5.http.impl.cookie.BasicExpiresHandler;
+import org.apache.hc.client5.http.utils.DateUtils;
import com.gargoylesoftware.htmlunit.BrowserVersion;
diff --git a/src/main/java/com/gargoylesoftware/htmlunit/httpclient/HtmlUnitHttpOnlyHandler.java b/src/main/java/com/gargoylesoftware/htmlunit/httpclient/HtmlUnitHttpOnlyHandler.java
index 9c70672b287..d94e88a1eb1 100644
--- a/src/main/java/com/gargoylesoftware/htmlunit/httpclient/HtmlUnitHttpOnlyHandler.java
+++ b/src/main/java/com/gargoylesoftware/htmlunit/httpclient/HtmlUnitHttpOnlyHandler.java
@@ -14,6 +14,13 @@
*/
package com.gargoylesoftware.htmlunit.httpclient;
+import org.apache.hc.client5.http.cookie.CommonCookieAttributeHandler;
+import org.apache.hc.client5.http.cookie.Cookie;
+import org.apache.hc.client5.http.cookie.CookieOrigin;
+import org.apache.hc.client5.http.cookie.MalformedCookieException;
+import org.apache.hc.client5.http.cookie.SetCookie;
+import org.apache.hc.client5.http.impl.cookie.BasicClientCookie;
+
/**
* Customized CookieAttributeHandler for handling of the httponly attribute.
*
@@ -27,13 +34,6 @@
* @author Ronald Brill
* @author John J Murdoch
*/
-import org.apache.http.cookie.CommonCookieAttributeHandler;
-import org.apache.http.cookie.Cookie;
-import org.apache.http.cookie.CookieOrigin;
-import org.apache.http.cookie.MalformedCookieException;
-import org.apache.http.cookie.SetCookie;
-import org.apache.http.impl.cookie.BasicClientCookie;
-
final class HtmlUnitHttpOnlyHandler implements CommonCookieAttributeHandler {
private static final String HTTPONLY_ATTR = "httponly";
diff --git a/src/main/java/com/gargoylesoftware/htmlunit/httpclient/HtmlUnitPathHandler.java b/src/main/java/com/gargoylesoftware/htmlunit/httpclient/HtmlUnitPathHandler.java
index d0bb4205b3a..635ff843aa2 100644
--- a/src/main/java/com/gargoylesoftware/htmlunit/httpclient/HtmlUnitPathHandler.java
+++ b/src/main/java/com/gargoylesoftware/htmlunit/httpclient/HtmlUnitPathHandler.java
@@ -16,10 +16,10 @@
import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.HTTP_COOKIE_EXTRACT_PATH_FROM_LOCATION;
-import org.apache.http.cookie.Cookie;
-import org.apache.http.cookie.CookieOrigin;
-import org.apache.http.cookie.MalformedCookieException;
-import org.apache.http.impl.cookie.BasicPathHandler;
+import org.apache.hc.client5.http.cookie.Cookie;
+import org.apache.hc.client5.http.cookie.CookieOrigin;
+import org.apache.hc.client5.http.cookie.MalformedCookieException;
+import org.apache.hc.client5.http.impl.cookie.BasicPathHandler;
import com.gargoylesoftware.htmlunit.BrowserVersion;
diff --git a/src/main/java/com/gargoylesoftware/htmlunit/httpclient/HtmlUnitRedirectStrategie.java b/src/main/java/com/gargoylesoftware/htmlunit/httpclient/HtmlUnitRedirectStrategie.java
index 2f8dbb30275..fe3369c8b7d 100644
--- a/src/main/java/com/gargoylesoftware/htmlunit/httpclient/HtmlUnitRedirectStrategie.java
+++ b/src/main/java/com/gargoylesoftware/htmlunit/httpclient/HtmlUnitRedirectStrategie.java
@@ -14,11 +14,11 @@
*/
package com.gargoylesoftware.htmlunit.httpclient;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpResponse;
-import org.apache.http.ProtocolException;
-import org.apache.http.impl.client.DefaultRedirectStrategy;
-import org.apache.http.protocol.HttpContext;
+import org.apache.hc.client5.http.impl.DefaultRedirectStrategy;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.ProtocolException;
+import org.apache.hc.core5.http.protocol.HttpContext;
/**
* Customized DefaultRedirectStrategy for HtmlUnit.
diff --git a/src/main/java/com/gargoylesoftware/htmlunit/httpclient/HtmlUnitSSLConnectionSocketFactory.java b/src/main/java/com/gargoylesoftware/htmlunit/httpclient/HtmlUnitSSLConnectionSocketFactory.java
index 0741ebdc639..d10fd1fc281 100644
--- a/src/main/java/com/gargoylesoftware/htmlunit/httpclient/HtmlUnitSSLConnectionSocketFactory.java
+++ b/src/main/java/com/gargoylesoftware/htmlunit/httpclient/HtmlUnitSSLConnectionSocketFactory.java
@@ -40,13 +40,15 @@
import javax.net.ssl.SSLSocket;
import javax.net.ssl.X509ExtendedTrustManager;
-import org.apache.http.HttpHost;
-import org.apache.http.conn.ConnectTimeoutException;
-import org.apache.http.conn.ssl.DefaultHostnameVerifier;
-import org.apache.http.conn.ssl.NoopHostnameVerifier;
-import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.ssl.SSLContexts;
+import org.apache.hc.client5.http.ConnectTimeoutException;
+import org.apache.hc.client5.http.ssl.DefaultHostnameVerifier;
+import org.apache.hc.client5.http.ssl.NoopHostnameVerifier;
+import org.apache.hc.client5.http.ssl.SSLConnectionSocketFactory;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.protocol.HttpContext;
+import org.apache.hc.core5.ssl.SSLContexts;
+import org.apache.hc.core5.util.TimeValue;
+import org.apache.hc.core5.util.TimeValue;
import com.gargoylesoftware.htmlunit.WebClientOptions;
@@ -154,7 +156,7 @@ private static void configureSocket(final SSLSocket sslSocket, final HttpContext
*/
@Override
public Socket connectSocket(
- final int connectTimeout,
+ final TimeValue connectTimeout,
final Socket socket,
final HttpHost host,
final InetSocketAddress remoteAddress,
@@ -169,7 +171,7 @@ public Socket connectSocket(
socksProxy.getPort());
try {
//underlying.setSoTimeout(soTimeout);
- underlying.connect(remoteAddress, connectTimeout);
+ underlying.connect(remoteAddress, connectTimeout.toMillisecondsIntBound());
}
catch (final SocketTimeoutException ex) {
throw new ConnectTimeoutException("Connect to " + socksProxyAddress + " timed out");
diff --git a/src/main/java/com/gargoylesoftware/htmlunit/httpclient/HtmlUnitSameSiteHandler.java b/src/main/java/com/gargoylesoftware/htmlunit/httpclient/HtmlUnitSameSiteHandler.java
index c0ca3c74d04..bb0121909cb 100644
--- a/src/main/java/com/gargoylesoftware/htmlunit/httpclient/HtmlUnitSameSiteHandler.java
+++ b/src/main/java/com/gargoylesoftware/htmlunit/httpclient/HtmlUnitSameSiteHandler.java
@@ -15,19 +15,18 @@
package com.gargoylesoftware.htmlunit.httpclient;
import org.apache.commons.lang3.StringUtils;
+import org.apache.hc.client5.http.cookie.CommonCookieAttributeHandler;
+import org.apache.hc.client5.http.cookie.Cookie;
+import org.apache.hc.client5.http.cookie.CookieOrigin;
+import org.apache.hc.client5.http.cookie.MalformedCookieException;
+import org.apache.hc.client5.http.cookie.SetCookie;
+import org.apache.hc.client5.http.impl.cookie.BasicClientCookie;
/**
* Customized CookieAttributeHandler for handling of the samesite attribute.
*
* @author Ronald Brill
*/
-import org.apache.http.cookie.CommonCookieAttributeHandler;
-import org.apache.http.cookie.Cookie;
-import org.apache.http.cookie.CookieOrigin;
-import org.apache.http.cookie.MalformedCookieException;
-import org.apache.http.cookie.SetCookie;
-import org.apache.http.impl.cookie.BasicClientCookie;
-
final class HtmlUnitSameSiteHandler implements CommonCookieAttributeHandler {
private static final String SAMESITE_ATTR = "samesite";
diff --git a/src/main/java/com/gargoylesoftware/htmlunit/httpclient/HtmlUnitVersionAttributeHandler.java b/src/main/java/com/gargoylesoftware/htmlunit/httpclient/HtmlUnitVersionAttributeHandler.java
index a9d9517ec03..6f46847d071 100644
--- a/src/main/java/com/gargoylesoftware/htmlunit/httpclient/HtmlUnitVersionAttributeHandler.java
+++ b/src/main/java/com/gargoylesoftware/htmlunit/httpclient/HtmlUnitVersionAttributeHandler.java
@@ -14,11 +14,10 @@
*/
package com.gargoylesoftware.htmlunit.httpclient;
-import org.apache.http.cookie.ClientCookie;
-import org.apache.http.cookie.CommonCookieAttributeHandler;
-import org.apache.http.cookie.MalformedCookieException;
-import org.apache.http.cookie.SetCookie;
-import org.apache.http.impl.cookie.AbstractCookieAttributeHandler;
+import org.apache.hc.client5.http.cookie.CommonCookieAttributeHandler;
+import org.apache.hc.client5.http.cookie.MalformedCookieException;
+import org.apache.hc.client5.http.cookie.SetCookie;
+import org.apache.hc.client5.http.impl.cookie.AbstractCookieAttributeHandler;
/**
* VersionAttributeHandler for HtmlUnit.
@@ -43,11 +42,14 @@ public void parse(final SetCookie cookie, final String value) throws MalformedCo
catch (final NumberFormatException e) {
// ignore invalid versions
}
- cookie.setVersion(version);
+ // TODO
+ //cookie.setVersion(version);
}
@Override
public String getAttributeName() {
- return ClientCookie.VERSION_ATTR;
+ // TODO
+ //return SetCookie.VERSION_ATTR;
+ return null;
}
}
diff --git a/src/main/java/com/gargoylesoftware/htmlunit/httpclient/SocksConnectionSocketFactory.java b/src/main/java/com/gargoylesoftware/htmlunit/httpclient/SocksConnectionSocketFactory.java
index 989590f9fdf..5e4ac8c89da 100644
--- a/src/main/java/com/gargoylesoftware/htmlunit/httpclient/SocksConnectionSocketFactory.java
+++ b/src/main/java/com/gargoylesoftware/htmlunit/httpclient/SocksConnectionSocketFactory.java
@@ -19,12 +19,12 @@
import java.net.Proxy;
import java.net.Socket;
-import org.apache.http.HttpHost;
-import org.apache.http.conn.socket.PlainConnectionSocketFactory;
-import org.apache.http.protocol.HttpContext;
+import org.apache.hc.client5.http.socket.PlainConnectionSocketFactory;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.protocol.HttpContext;
/**
- * SOCKS aware {@link org.apache.http.conn.socket.ConnectionSocketFactory}.
+ * SOCKS aware {@link org.apache.hc.client5.http.socket.ConnectionSocketFactory}.
*
* @author Ahmed Ashour
* @author Ronald Brill
diff --git a/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/URLSearchParams.java b/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/URLSearchParams.java
index e3202f3502c..31ee913bb08 100644
--- a/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/URLSearchParams.java
+++ b/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/URLSearchParams.java
@@ -20,6 +20,7 @@
import static com.gargoylesoftware.htmlunit.javascript.configuration.SupportedBrowser.FF;
import static com.gargoylesoftware.htmlunit.javascript.configuration.SupportedBrowser.FF78;
+import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
@@ -27,7 +28,7 @@
import java.util.ListIterator;
import org.apache.commons.lang3.StringUtils;
-import org.apache.http.client.utils.URLEncodedUtils;
+import org.apache.hc.core5.net.URLEncodedUtils;
import com.gargoylesoftware.htmlunit.FormEncodingType;
import com.gargoylesoftware.htmlunit.WebRequest;
@@ -333,7 +334,7 @@ public Object values() {
*/
@JsxFunction(functionName = "toString")
public String jsToString() {
- return URLEncodedUtils.format(NameValuePair.toHttpClient(params_), "UTF-8");
+ return URLEncodedUtils.format(NameValuePair.toHttpClient(params_), StandardCharsets.UTF_8);
}
/**
diff --git a/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/xml/XMLHttpRequest.java b/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/xml/XMLHttpRequest.java
index a4e3856c5b3..8766942a534 100644
--- a/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/xml/XMLHttpRequest.java
+++ b/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/xml/XMLHttpRequest.java
@@ -51,9 +51,9 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.http.HttpStatus;
-import org.apache.http.NoHttpResponseException;
-import org.apache.http.auth.UsernamePasswordCredentials;
+import org.apache.hc.client5.http.auth.UsernamePasswordCredentials;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.NoHttpResponseException;
import com.gargoylesoftware.htmlunit.AjaxController;
import com.gargoylesoftware.htmlunit.BrowserVersion;
@@ -517,7 +517,7 @@ public void open(final String method, final Object urlParam, final Object asyncP
passwordCred = password.toString();
}
- request.setCredentials(new UsernamePasswordCredentials(userCred, passwordCred));
+ request.setCredentials(new UsernamePasswordCredentials(userCred, passwordCred.toCharArray()));
}
webRequest_ = request;
}
diff --git a/src/main/java/com/gargoylesoftware/htmlunit/util/Cookie.java b/src/main/java/com/gargoylesoftware/htmlunit/util/Cookie.java
index c9969705b0c..01aab29b907 100644
--- a/src/main/java/com/gargoylesoftware/htmlunit/util/Cookie.java
+++ b/src/main/java/com/gargoylesoftware/htmlunit/util/Cookie.java
@@ -23,8 +23,7 @@
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
-import org.apache.http.cookie.ClientCookie;
-import org.apache.http.impl.cookie.BasicClientCookie;
+import org.apache.hc.client5.http.impl.cookie.BasicClientCookie;
/**
* A cookie. This class is immutable.
@@ -36,7 +35,7 @@
*/
public class Cookie implements Serializable {
- private ClientCookie httpClientCookie_;
+ private org.apache.hc.client5.http.cookie.Cookie httpClientCookie_;
/**
* Creates a new cookie with the specified name and value which applies to the specified domain.
@@ -85,7 +84,7 @@ public Cookie(final String domain, final String name, final String value, final
cookie.setDomain(domain);
// BasicDomainHandler.match(Cookie, CookieOrigin) checks the attib also (see #333)
- cookie.setAttribute(ClientCookie.DOMAIN_ATTR, domain);
+ cookie.setAttribute(BasicClientCookie.DOMAIN_ATTR, domain);
cookie.setPath(path);
cookie.setExpiryDate(expires);
@@ -101,7 +100,7 @@ public Cookie(final String domain, final String name, final String value, final
* Creates a new HtmlUnit cookie from the HttpClient cookie provided.
* @param clientCookie the HttpClient cookie
*/
- public Cookie(final ClientCookie clientCookie) {
+ public Cookie(final org.apache.hc.client5.http.cookie.Cookie clientCookie) {
httpClientCookie_ = clientCookie;
}
@@ -246,7 +245,7 @@ public int hashCode() {
* Converts this cookie to an HttpClient cookie.
* @return an HttpClient version of this cookie
*/
- public org.apache.http.cookie.Cookie toHttpClient() {
+ public org.apache.hc.client5.http.cookie.Cookie toHttpClient() {
return httpClientCookie_;
}
@@ -255,8 +254,8 @@ public org.apache.http.cookie.Cookie toHttpClient() {
* @param cookies the cookies to be converted
* @return the specified cookies, as HttpClient cookies
*/
- public static List toHttpClient(final Collection cookies) {
- final ArrayList array = new ArrayList<>(cookies.size());
+ public static List toHttpClient(final Collection cookies) {
+ final ArrayList array = new ArrayList<>(cookies.size());
final Iterator it = cookies.iterator();
while (it.hasNext()) {
array.add(it.next().toHttpClient());
@@ -269,10 +268,10 @@ public static List toHttpClient(final Collection<
* @param cookies the cookies to be converted
* @return the specified HttpClient cookies, as cookies
*/
- public static List fromHttpClient(final List cookies) {
+ public static List fromHttpClient(final List cookies) {
final List list = new ArrayList<>(cookies.size());
- for (final org.apache.http.cookie.Cookie c : cookies) {
- list.add(new Cookie((ClientCookie) c));
+ for (final org.apache.hc.client5.http.cookie.Cookie c : cookies) {
+ list.add(new Cookie(c));
}
return list;
}
diff --git a/src/main/java/com/gargoylesoftware/htmlunit/util/NameValuePair.java b/src/main/java/com/gargoylesoftware/htmlunit/util/NameValuePair.java
index 5c3b6a15087..be597cbc5ea 100644
--- a/src/main/java/com/gargoylesoftware/htmlunit/util/NameValuePair.java
+++ b/src/main/java/com/gargoylesoftware/htmlunit/util/NameValuePair.java
@@ -18,8 +18,8 @@
import java.util.ArrayList;
import java.util.List;
-import org.apache.http.message.BasicNameValuePair;
-import org.apache.http.util.LangUtils;
+import org.apache.hc.core5.http.message.BasicNameValuePair;
+import org.apache.hc.core5.util.LangUtils;
/**
* A name/value pair.
@@ -98,9 +98,9 @@ public String toString() {
* @param pairs the name/value pairs to convert
* @return the converted name/value pairs
*/
- public static org.apache.http.NameValuePair[] toHttpClient(final NameValuePair[] pairs) {
- final org.apache.http.NameValuePair[] pairs2 =
- new org.apache.http.NameValuePair[pairs.length];
+ public static org.apache.hc.core5.http.NameValuePair[] toHttpClient(final NameValuePair[] pairs) {
+ final org.apache.hc.core5.http.NameValuePair[] pairs2 =
+ new org.apache.hc.core5.http.NameValuePair[pairs.length];
for (int i = 0; i < pairs.length; i++) {
final NameValuePair pair = pairs[i];
pairs2[i] = new BasicNameValuePair(pair.getName(), pair.getValue());
@@ -113,8 +113,8 @@ public static org.apache.http.NameValuePair[] toHttpClient(final NameValuePair[]
* @param pairs the name/value pairs to convert
* @return the converted name/value pairs
*/
- public static List toHttpClient(final List pairs) {
- final List resultingPairs = new ArrayList<>(pairs.size());
+ public static List toHttpClient(final List pairs) {
+ final List resultingPairs = new ArrayList<>(pairs.size());
for (int i = 0; i < pairs.size(); i++) {
final NameValuePair pair = pairs.get(i);
resultingPairs.add(new BasicNameValuePair(pair.getName(), pair.getValue()));
diff --git a/src/main/java/com/gargoylesoftware/htmlunit/util/StringUtils.java b/src/main/java/com/gargoylesoftware/htmlunit/util/StringUtils.java
index 969eaa88da1..d8a07cc3652 100644
--- a/src/main/java/com/gargoylesoftware/htmlunit/util/StringUtils.java
+++ b/src/main/java/com/gargoylesoftware/htmlunit/util/StringUtils.java
@@ -18,7 +18,7 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import org.apache.http.client.utils.DateUtils;
+import org.apache.hc.client5.http.utils.DateUtils;
import com.gargoylesoftware.htmlunit.html.impl.Color;
diff --git a/src/test/java/com/gargoylesoftware/htmlunit/AbstractPageTest.java b/src/test/java/com/gargoylesoftware/htmlunit/AbstractPageTest.java
index 9c72d861a82..baeef59c536 100644
--- a/src/test/java/com/gargoylesoftware/htmlunit/AbstractPageTest.java
+++ b/src/test/java/com/gargoylesoftware/htmlunit/AbstractPageTest.java
@@ -14,7 +14,7 @@
*/
package com.gargoylesoftware.htmlunit;
-import static org.apache.http.client.utils.DateUtils.formatDate;
+import static org.apache.hc.client5.http.utils.DateUtils.formatDate;
import java.util.ArrayList;
import java.util.Date;
diff --git a/src/test/java/com/gargoylesoftware/htmlunit/CacheTest.java b/src/test/java/com/gargoylesoftware/htmlunit/CacheTest.java
index a3784c88a1b..97be9525764 100644
--- a/src/test/java/com/gargoylesoftware/htmlunit/CacheTest.java
+++ b/src/test/java/com/gargoylesoftware/htmlunit/CacheTest.java
@@ -14,7 +14,7 @@
*/
package com.gargoylesoftware.htmlunit;
-import static org.apache.http.client.utils.DateUtils.formatDate;
+import static org.apache.hc.client5.http.utils.DateUtils.formatDate;
import static org.easymock.EasyMock.createMock;
import static org.easymock.EasyMock.expect;
import static org.easymock.EasyMock.expectLastCall;
diff --git a/src/test/java/com/gargoylesoftware/htmlunit/CookieManager3Test.java b/src/test/java/com/gargoylesoftware/htmlunit/CookieManager3Test.java
index 081c8e467ed..8b6ea872ab7 100644
--- a/src/test/java/com/gargoylesoftware/htmlunit/CookieManager3Test.java
+++ b/src/test/java/com/gargoylesoftware/htmlunit/CookieManager3Test.java
@@ -21,10 +21,11 @@
import java.util.Date;
import java.util.List;
-import org.apache.http.Header;
-import org.apache.http.cookie.CookieOrigin;
-import org.apache.http.impl.cookie.DefaultCookieSpec;
-import org.apache.http.message.BasicHeader;
+import org.apache.hc.client5.http.cookie.CookieOrigin;
+import org.apache.hc.client5.http.cookie.CookieSpec;
+import org.apache.hc.client5.http.impl.cookie.RFC6265StrictSpec;
+import org.apache.hc.core5.http.Header;
+import org.apache.hc.core5.http.message.BasicHeader;
import org.junit.Test;
import com.gargoylesoftware.htmlunit.util.Cookie;
@@ -106,9 +107,11 @@ public void basicBehavior() {
@Test
public void httpClientParsesCookiesQuotedValuesCorrectly() throws Exception {
final Header header = new BasicHeader("Set-Cookie", "first=\"hello world\"");
- final DefaultCookieSpec spec = new DefaultCookieSpec();
+ // TODO
+ //final DefaultCookieSpec spec = new DefaultCookieSpec();
+ final CookieSpec spec = new RFC6265StrictSpec();
final CookieOrigin origin = new CookieOrigin("localhost", 80, "/", false);
- final List list = spec.parse(header, origin);
+ final List list = spec.parse(header, origin);
assertEquals(1, list.size());
assertEquals("\"hello world\"", list.get(0).getValue());
}
diff --git a/src/test/java/com/gargoylesoftware/htmlunit/CookieManager5Test.java b/src/test/java/com/gargoylesoftware/htmlunit/CookieManager5Test.java
index 1e06ad8fdf3..f897a4a77f7 100644
--- a/src/test/java/com/gargoylesoftware/htmlunit/CookieManager5Test.java
+++ b/src/test/java/com/gargoylesoftware/htmlunit/CookieManager5Test.java
@@ -26,7 +26,7 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import org.apache.http.client.utils.DateUtils;
+import org.apache.hc.client5.http.utils.DateUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
diff --git a/src/test/java/com/gargoylesoftware/htmlunit/CookieManagerTest.java b/src/test/java/com/gargoylesoftware/htmlunit/CookieManagerTest.java
index 1202301df15..296f4f5eb92 100644
--- a/src/test/java/com/gargoylesoftware/htmlunit/CookieManagerTest.java
+++ b/src/test/java/com/gargoylesoftware/htmlunit/CookieManagerTest.java
@@ -22,7 +22,7 @@
import java.util.List;
import java.util.Map;
-import org.apache.http.client.utils.DateUtils;
+import org.apache.hc.client5.http.utils.DateUtils;
import org.junit.After;
import org.junit.Test;
import org.junit.runner.RunWith;
diff --git a/src/test/java/com/gargoylesoftware/htmlunit/DefaultCredentialsProvider2Test.java b/src/test/java/com/gargoylesoftware/htmlunit/DefaultCredentialsProvider2Test.java
index 524de695210..85e9c779b25 100644
--- a/src/test/java/com/gargoylesoftware/htmlunit/DefaultCredentialsProvider2Test.java
+++ b/src/test/java/com/gargoylesoftware/htmlunit/DefaultCredentialsProvider2Test.java
@@ -60,7 +60,7 @@ public void basicAuthenticationWrongUserName() throws Exception {
// wrong user name
getWebClient().getCredentialsProvider().clear();
- ((DefaultCredentialsProvider) getWebClient().getCredentialsProvider()).addCredentials("joe", "jetty");
+ ((DefaultCredentialsProvider) getWebClient().getCredentialsProvider()).addCredentials("joe", "jetty".toCharArray());
try {
loadPage("Hi There");
@@ -80,7 +80,7 @@ public void basicAuthenticationWrongPassword() throws Exception {
// wrong user name
getWebClient().getCredentialsProvider().clear();
- ((DefaultCredentialsProvider) getWebClient().getCredentialsProvider()).addCredentials("jetty", "secret");
+ ((DefaultCredentialsProvider) getWebClient().getCredentialsProvider()).addCredentials("jetty", "secret".toCharArray());
try {
loadPage("Hi There");
@@ -111,7 +111,7 @@ public void basicAuthentication_singleAuthenticaiton() throws Exception {
logger.addAppender(writerAppender);
try {
- ((DefaultCredentialsProvider) getWebClient().getCredentialsProvider()).addCredentials("jetty", "jetty");
+ ((DefaultCredentialsProvider) getWebClient().getCredentialsProvider()).addCredentials("jetty", "jetty".toCharArray());
loadPage("Hi There");
int unauthorizedCount = StringUtils.countMatches(stringWriter.toString(), "HTTP/1.1 401");
@@ -310,7 +310,7 @@ public void basicAuthenticationUserFromUrlOverwriteDefaultCredentials() throws E
getMockWebConnection().setDefaultResponse(html);
getWebClient().getCredentialsProvider().clear();
- ((DefaultCredentialsProvider) getWebClient().getCredentialsProvider()).addCredentials("jetty", "jetty");
+ ((DefaultCredentialsProvider) getWebClient().getCredentialsProvider()).addCredentials("jetty", "jetty".toCharArray());
// use default credentials
loadPageWithAlerts(URL_FIRST);
@@ -345,7 +345,7 @@ public void basicAuthenticationUserFromUrlOverwriteWrongDefaultCredentials() thr
getMockWebConnection().setDefaultResponse(html);
getWebClient().getCredentialsProvider().clear();
- ((DefaultCredentialsProvider) getWebClient().getCredentialsProvider()).addCredentials("joe", "hack");
+ ((DefaultCredentialsProvider) getWebClient().getCredentialsProvider()).addCredentials("joe", "hack".toCharArray());
// use default wrong credentials
try {
@@ -390,7 +390,7 @@ public void basicAuthenticationXHR() throws Exception {
+ "xhr.send('');\n"
+ "