Skip to content

API works only partially when using an HTTP proxy #92

@xylo

Description

@xylo

TL;DR: Please add support for HTTP proxies in all API parts using Apache HttpClient

Long version:

I tried to use the nextcloud-java-api within a company network which requires me to use an HTTP proxy to access the Nextcloud instance.

This is my sample code demonstrating that parts of the API work with an HTTP proxy an some do not work (the ones using Apache HttpClient):

System.setProperty("http.proxyHost", "proxy");
System.setProperty("http.proxyPort", "8000");
System.setProperty("https.proxyHost", "proxy");
System.setProperty("https.proxyPort", "8000");

NextcloudConnectorconnector = new org.aarboard.nextcloud.api.NextcloudConnector("my_cloud_host", true, 443, user, password);
System.out.println("connector.getServerVersion() = " + connector.getServerVersion());  <-- works fine because it does not use Apache HttpClient

User user = connector.getUser("my_user_name");  <-- fails with a timeout because Apache HttpClient doesn't automatically use the HTTP proxy settings of Java

The problem is that in ConnectorCommon.java the HttpClient is hard coded via

HTTPC_CLIENT = HttpAsyncClients.createDefault();

So this could be either replaced by a function which can be overwritten so that the user himself can set up an HttpClient with the appropriate proxy configuration or the API could read the Java http proxy settings and set the corresponding properties of the HttpClient.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions