Update Apache HttpComponents Client dependency adding support for HTTP2.#515
Update Apache HttpComponents Client dependency adding support for HTTP2.#515PetrusHahol wants to merge 14 commits intolookfirst:masterfrom
Conversation
|
The redirect strategy is meant to handle the additional HTTP methods from WebDAV that are not handled in the default implementation from HTTP components. Thus a server can reply with a redirect for |
|
I just stumbled across the same problem and I would also like this feature.
I did not check, the code here. But is there a unit test, that verifies this? Maybe I can assist |
Unfortanatly there is no unit tests for it, I would be very happy if you would find a proper solution for redirect stratagy functionality. I am following up this thread and ready to help you to test it. |
f34c128 to
a3531b6
Compare
|
To me it looks like the custom redirect strategy is no longer required as
Footnotes
|
a3531b6 to
49a37c9
Compare
|
@dkocher I agree with this, but it changes the Sardine API. I just want to confirm that this will be a MAJOR version change on the library. |
|
@dkocher That link isn't loading for me, but what I'm thinking about are the few places where things change from String -> char[]. Essentially all the chances in Sardine.java. |
|
Wondering if this is still interoperable with Sharepoint WebDAV using NTLM.
|
| */ | ||
| List<String> getPrincipalCollectionSet(String url) throws IOException; | ||
|
|
||
| void enableHttp2(); |
There was a problem hiding this comment.
Missing Javadoc describing implications.
| return DateUtils.parseDate(value, SUPPORTED_DATE_FORMATS); | ||
| final Instant parsedInstant = DateUtils.parseDate(value, Arrays.stream(SUPPORTED_DATE_FORMATS) | ||
| .map(pattern -> DateTimeFormatter.ofPattern(pattern, Locale.US).withZone(ZoneId.of("GMT"))).toArray(DateTimeFormatter[]::new)); | ||
| if (null == parsedInstant) |
| sardine.delete(url); | ||
| } | ||
| } | ||
|
|
There was a problem hiding this comment.
Are we removing this test because it is no longer necessary or just don't want to fix it or...
There was a problem hiding this comment.
Too lazy to fix the test…
| @Test | ||
| public void testParseDate() throws Exception | ||
| { | ||
| assertNotNull(SardineUtil.parseDate("1970-01-01T12:00:00Z")); |
There was a problem hiding this comment.
what's the point of this test? would be good to document the "why"...
There was a problem hiding this comment.
No particular reason for this addition. Was accidentally included when transitioning implementation.
| { | ||
| provider.setCredentials( | ||
| new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT, AuthScope.ANY_REALM, AuthSchemes.NTLM), | ||
| new AuthScope(null, null, -1, null, StandardAuthScheme.NTLM), |
There was a problem hiding this comment.
Why are we removing the constants?
There was a problem hiding this comment.
The constants seem no longer to exist.
| new GzipDecompressingEntity(entity)); | ||
| } | ||
| }); | ||
|
|
There was a problem hiding this comment.
Is there no longer a "simple" way to do this?
There was a problem hiding this comment.
Should just toggle contentCompressionDisabled in the client builder instead.
There was a problem hiding this comment.
There is no setter in the builder to enable. Can be just a no-op then as it is enabled by default?
| body.setLockscope(scopeType); | ||
| Locktype lockType = new Locktype(); | ||
| lockType.setWrite(new Write()); | ||
| body.setLocktype(lockType); |
There was a problem hiding this comment.
Unused. Will open a separate pull request.
dkocher
left a comment
There was a problem hiding this comment.
Should also review deprecated usage of ConnectionSocketFactory.
dkocher
left a comment
There was a problem hiding this comment.
Not sure if we should maintain a separate branch that retains the 4.x HttpComponents dependency.
|
Hello everyone, Thanks for the PR, we would also need sardine with http5. Exception stack trace: How we use sardine: The port number is randomized, so it's ok that there are different port numbers in the different code blocks, it just took me several runs until I collected all the information. We create the instance on localhost with: The log with http5 looks like this: The same test with Sardine with http4, log output: So the http4 version apparently received a 401 Unauthorized at first, but then it healed itself so it was tried again with BasicAuth. After that we received 207 multi status and everything was fine. Do you have an idea why our application doesn't yet work with the http5 branch? Cheers |
| if (httpMajorVersion != null){ | ||
| request.setVersion(new ProtocolVersion("HTTP", httpMajorVersion, 0)); | ||
| } | ||
| HttpContext requestLocalContext = new HttpClientContext(context); |
There was a problem hiding this comment.
| HttpContext requestLocalContext = new HttpClientContext(context); | |
| HttpContext requestLocalContext = context; |
removing the localContext would solve our auth problems as HttpClient5 seems to cache the previous authentication.
So we get one 401, then HttpClient selects the correct authenticator and from then, we get 2xx responses and our tests pass
Suggested change:
protected <T> T execute(HttpClientContext context, HttpUriRequestBase request, HttpClientResponseHandler<T> responseHandler)
throws IOException
{
Integer httpMajorVersion = (Integer) context.getAttribute(HTTP_MAJOR_VERSION);
if (httpMajorVersion != null){
request.setVersion(new ProtocolVersion("HTTP", httpMajorVersion, 0));
}
try
{
if (responseHandler != null)
{
return this.client.execute(request, context, responseHandler);
}
else
{
return (T) this.client.execute(request, context);
}
}
catch (HttpResponseException e)
{
// Don't abort if we get this exception, caller may want to repeat request.
throw e;
}
catch (IOException e)
{
request.abort();
throw e;
}
}|
I implemented a unittest and a fix in PetrusHahol#1 |
That would most probably cause regressions for the following issues |
|
Hello @dkocher, |
|
Following the trail to here, seems a positive development for a sardine 6.x. |
|
Hello @dkocher Any news on this issue? We would also be interested in a version with httpclient5. |
Hi,
Here are the changes to support Apache Client 5. As discussed in the related issue, some methods now function quite differently. I have successfully migrated the main business logic and tests, but there is still one class that I am unable to rewrite due to a lack of knowledge about the previous implementation (src/main/java/com/github/sardine/impl/SardineRedirectStrategy.java).
I would appreciate any ideas from the community on how to address this issue or any assistance in resolving it.
Additionally, I introduced the enableHttp2 method in the Sardine interface.
I will monitor this pull request discussion and aim to finalize it as soon as possible.
Fixes #333