WIP: Update Apache HttpClient to version 5.x #372
Draft
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.
Sneak preview of the changes made so far. Note that this PR is not complete, but work-in-progress. See below for some comments from my side.
HttpWebConnection
This is of course the place where most of the changes were made. There are still a lot of TODOs:
Other Changes
pom.xml
Still uses HC 4.x for the tests. I tried to rework the LocalTestServer to use 5.x classes, but some of them are no longer available on Maven Central. Maybe we can replace this later. I also had to add httplient as test dependeny since the tests-jar needs it.
The client is no longer required
DefaultCredentialsProvider
Now implements CredentialsStore. The ANY_* constants are no longer provided so I recreated them here for now. AuthScope takes protocol and auth scheme as additional parameters now. Passwords are char[] now.
HtmlUnitBrowserCompatCookieHeaderValueFormatter
We can no longer overwrite certain methods of BasicHeaderValueFormatter so I had to reimplement this class completely, i.e. I copied the relevant code.
HtmlUnitBrowserCompatCookieSpec
There are a couple of changes here and some TODOs. In HC 5.x, cookies don't provide version and comment any longer. Since the current code depends on the version attribute, we have to carefully review/rework this class.
NetscapeDraftHeaderParser
This class is no longer available in HC 5.x. I readded it as HtmlUnitBrowserCompatCookieSpec relies heavily on it at the moment. We need to check if all copyright requirements are satisfied.
HtmlUnitVersionAttributeHandler
Since the version cookie attribute is no longer supported, we can probably delete this class.
Removed
HtmlUnitSSLConnectionSocketFactory / SocksConnectionSocketFactory
Cannot set plain/SSL socket factories any longer. Most functionality has been moved to HttpWebConnection. Once we are confident that all is covered elsewhere, we can remove these classes.
CookieManager3Test
The DefaultCookieSpec used in the test previously is no longer available. Don't know if we still need the httpClientParsesCookiesQuotedValuesCorrectly test case.
HtmlUnitCookieStoreTest
Had to implement the store-contains-the-cookie check in a different way as we can no longer inherit from the now final BasicClientCookie class.
HttpWebConnection3Test
HC 5.x now uses "Connection: keep-alive" (lower-case) so I had to adapt the expectations.
The remaining modifications are mostly trivial.