Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Apache HttpComponents Client dependency adding support for HTTP2. #515

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

PetrusHahol
Copy link

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

@dkocher dkocher marked this pull request as draft August 22, 2024 10:21
@dkocher
Copy link
Collaborator

dkocher commented Aug 22, 2024

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 PROPFIND and the entity is properly sent to the redirect URI.

@rPraml
Copy link

rPraml commented Sep 26, 2024

I just stumbled across the same problem and I would also like this feature.

The redirect strategy is meant to handle the additional HTTP methods from WebDAV that are not handled in the default implementation from HTTP components

I did not check, the code here. But is there a unit test, that verifies this? Maybe I can assist

@PetrusHahol
Copy link
Author

I just stumbled across the same problem and I would also like this feature.

The redirect strategy is meant to handle the additional HTTP methods from WebDAV that are not handled in the default implementation from HTTP components

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.

@dkocher dkocher force-pushed the feature/ApacheClient5 branch from f34c128 to a3531b6 Compare January 10, 2025 13:13
@dkocher
Copy link
Collaborator

dkocher commented Jan 10, 2025

@dkocher dkocher force-pushed the feature/ApacheClient5 branch from a3531b6 to 49a37c9 Compare January 10, 2025 14:07
@dkocher dkocher marked this pull request as ready for review January 10, 2025 14:07
@dkocher dkocher changed the title Feature/apache client5 Update Apache HttpComponents Client dependency adding support for HTTP2. Jan 10, 2025
@dkocher dkocher requested a review from lookfirst January 10, 2025 14:09
@lookfirst
Copy link
Owner

@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
Copy link
Collaborator

dkocher commented Jan 10, 2025

@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.

Do you mean because of the return value of createDefaultRedirectStrategy 1?

Footnotes

  1. https://github.com/lookfirst/sardine/pull/515/files#diff-d0c6bff269a6dc37447fd635eba385548f6fe3f44394384ffe82ebb496a4ac0fR1172

@lookfirst
Copy link
Owner

@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.

	void setCredentials(String username, String password);
	void setCredentials(String username, char[] password);

@dkocher
Copy link
Collaborator

dkocher commented Jan 10, 2025

Wondering if this is still interoperable with Sharepoint WebDAV using NTLM.

  • @deprecated Do not use. the NTLM authentication scheme is no longer supported.
  • Consider using Basic or Bearer authentication with TLS instead.

@@ -548,6 +547,8 @@ public interface Sardine
*/
List<String> getPrincipalCollectionSet(String url) throws IOException;

void enableHttp2();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yoda logic.

// Backward compatibility
failure.initCause(e);
throw failure;
throw new IOException("Not a valid DAV response", e);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Formatting?

sardine.delete(url);
}
}

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we removing this test because it is no longer necessary or just don't want to fix it or...

@@ -34,6 +34,7 @@ public class SardineUtilTest
@Test
public void testParseDate() throws Exception
{
assertNotNull(SardineUtil.parseDate("1970-01-01T12:00:00Z"));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the point of this test? would be good to document the "why"...

if (username != null)
{
provider.setCredentials(
new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT, AuthScope.ANY_REALM, AuthSchemes.NTLM),
new AuthScope(null, null, -1, null, StandardAuthScheme.NTLM),
Copy link
Owner

@lookfirst lookfirst Jan 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we removing the constants?

new GzipDecompressingEntity(entity));
}
});

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there no longer a "simple" way to do this?

@@ -390,7 +399,6 @@ public List<DavResource> list(String url, int depth, java.util.Set<QName> props)
prop.setGetcontenttype(objectFactory.createGetcontenttype());
prop.setResourcetype(objectFactory.createResourcetype());
prop.setGetetag(objectFactory.createGetetag());
prop.setLockdiscovery(objectFactory.createLockdiscovery());
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this removed?

body.setLockscope(scopeType);
Locktype lockType = new Locktype();
lockType.setWrite(new Write());
body.setLocktype(lockType);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why removed?

@@ -861,25 +868,25 @@ public void put(String url, InputStream dataStream, String contentType, boolean
@Override
public void put(String url, InputStream dataStream, String contentType, boolean expectContinue, long contentLength) throws IOException
{
InputStreamEntity entity = new InputStreamEntity(dataStream, contentLength);
InputStreamEntity entity = new InputStreamEntity(dataStream, contentLength, contentType != null ? ContentType.create(contentType) : null);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add a helper function since this is duplicated a bunch of times? Would be good to effectively document this.

{
this(URI.create(uri));
this(URI.create(url));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why rename this to url when it is called by URI.create(...)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update to Apache HttpClient v5
4 participants