Browse Source

Send Host header in rTorrent requests, fixes #563

pull/596/head v2.5.20-beta3
Eric Kok 3 years ago
parent
commit
276593f49e
  1. 10
      app/src/main/java/de/timroes/axmlrpc/XMLRPCClient.java
  2. 3
      app/src/main/java/org/transdroid/daemon/adapters/rTorrent/RTorrentAdapter.java

10
app/src/main/java/de/timroes/axmlrpc/XMLRPCClient.java

@ -146,6 +146,8 @@ public class XMLRPCClient { @@ -146,6 +146,8 @@ public class XMLRPCClient {
private DefaultHttpClient httpclient;
private String hostname;
private String url;
private Map<Long,Caller> backgroundCalls = new ConcurrentHashMap<Long, Caller>();
@ -161,11 +163,12 @@ public class XMLRPCClient { @@ -161,11 +163,12 @@ public class XMLRPCClient {
* @param url The URL to send the requests to.
* @param flags A combination of flags to be set.
*/
public XMLRPCClient(DefaultHttpClient httpclient, String url, int flags) {
public XMLRPCClient(DefaultHttpClient httpclient, String hostname, String url, int flags) {
this.serializerHandler = new SerializerHandler(flags);
this.httpclient = httpclient;
this.hostname = hostname;
this.url = url;
this.flags = flags;
@ -181,8 +184,8 @@ public class XMLRPCClient { @@ -181,8 +184,8 @@ public class XMLRPCClient {
* @param httpclient The already-initialized Apache HttpClient to use for connection.
* @param url The url to send the requests to.
*/
public XMLRPCClient(DefaultHttpClient httpclient, String url) {
this(httpclient, url, FLAGS_NONE);
public XMLRPCClient(DefaultHttpClient httpclient, String hostname, String url) {
this(httpclient, hostname, url, FLAGS_NONE);
}
/**
@ -381,6 +384,7 @@ public class XMLRPCClient { @@ -381,6 +384,7 @@ public class XMLRPCClient {
HttpPost post = new HttpPost(url);
post.getParams().setParameter(ClientPNames.HANDLE_REDIRECTS, false);
post.setHeader(CONTENT_TYPE, TYPE_XML);
post.setHeader(HOST, hostname);
StringEntity entity = new StringEntity(c.getXML(), HTTP.UTF_8);
entity.setContentType(TYPE_XML);
post.setEntity(entity);

3
app/src/main/java/org/transdroid/daemon/adapters/rTorrent/RTorrentAdapter.java

@ -370,7 +370,8 @@ public class RTorrentAdapter implements IDaemonAdapter { @@ -370,7 +370,8 @@ public class RTorrentAdapter implements IDaemonAdapter {
private void initialise() throws DaemonException, MalformedURLException {
int flags = XMLRPCClient.FLAGS_8BYTE_INT;
this.rpcclient = new XMLRPCClient(HttpHelper.createStandardHttpClient(settings, true), buildWebUIUrl(), flags);
this.rpcclient = new XMLRPCClient(HttpHelper.createStandardHttpClient(settings, true),
settings.getAddress(), buildWebUIUrl(), flags);
}

Loading…
Cancel
Save