Add Proxy#scheme.
parent
2413366adb
commit
791323a5b0
|
@ -74,7 +74,7 @@ public class HttpUriRequestConverter {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (proxy != null) {
|
if (proxy != null) {
|
||||||
requestConfigBuilder.setProxy(new HttpHost(proxy.getHost(), proxy.getPort()));
|
requestConfigBuilder.setProxy(new HttpHost(proxy.getHost(), proxy.getPort(), proxy.getScheme()));
|
||||||
}
|
}
|
||||||
requestBuilder.setConfig(requestConfigBuilder.build());
|
requestBuilder.setConfig(requestConfigBuilder.build());
|
||||||
HttpUriRequest httpUriRequest = requestBuilder.build();
|
HttpUriRequest httpUriRequest = requestBuilder.build();
|
||||||
|
|
|
@ -2,6 +2,8 @@ package us.codecraft.webmagic.proxy;
|
||||||
|
|
||||||
public class Proxy {
|
public class Proxy {
|
||||||
|
|
||||||
|
private String scheme;
|
||||||
|
|
||||||
private String host;
|
private String host;
|
||||||
|
|
||||||
private int port;
|
private int port;
|
||||||
|
@ -11,8 +13,13 @@ public class Proxy {
|
||||||
private String password;
|
private String password;
|
||||||
|
|
||||||
public Proxy(String host, int port) {
|
public Proxy(String host, int port) {
|
||||||
|
this(host, port, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Proxy(String host, int port, String scheme) {
|
||||||
this.host = host;
|
this.host = host;
|
||||||
this.port = port;
|
this.port = port;
|
||||||
|
this.scheme = scheme;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Proxy(String host, int port, String username, String password) {
|
public Proxy(String host, int port, String username, String password) {
|
||||||
|
@ -22,7 +29,15 @@ public class Proxy {
|
||||||
this.password = password;
|
this.password = password;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getHost() {
|
public String getScheme() {
|
||||||
|
return scheme;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setScheme(String scheme) {
|
||||||
|
this.scheme = scheme;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getHost() {
|
||||||
return host;
|
return host;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,6 +62,7 @@ public class Proxy {
|
||||||
|
|
||||||
if (port != proxy.port) return false;
|
if (port != proxy.port) return false;
|
||||||
if (host != null ? !host.equals(proxy.host) : proxy.host != null) return false;
|
if (host != null ? !host.equals(proxy.host) : proxy.host != null) return false;
|
||||||
|
if (scheme != null ? !scheme.equals(proxy.scheme) : proxy.scheme != null) return false;
|
||||||
if (username != null ? !username.equals(proxy.username) : proxy.username != null) return false;
|
if (username != null ? !username.equals(proxy.username) : proxy.username != null) return false;
|
||||||
return password != null ? password.equals(proxy.password) : proxy.password == null;
|
return password != null ? password.equals(proxy.password) : proxy.password == null;
|
||||||
}
|
}
|
||||||
|
@ -55,6 +71,7 @@ public class Proxy {
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
int result = host != null ? host.hashCode() : 0;
|
int result = host != null ? host.hashCode() : 0;
|
||||||
result = 31 * result + port;
|
result = 31 * result + port;
|
||||||
|
result = 31 * result + (scheme != null ? scheme.hashCode() : 0);
|
||||||
result = 31 * result + (username != null ? username.hashCode() : 0);
|
result = 31 * result + (username != null ? username.hashCode() : 0);
|
||||||
result = 31 * result + (password != null ? password.hashCode() : 0);
|
result = 31 * result + (password != null ? password.hashCode() : 0);
|
||||||
return result;
|
return result;
|
||||||
|
@ -62,12 +79,8 @@ public class Proxy {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Proxy{" +
|
return String.format("Proxy{scheme='%1$s', host='%2$s', port=%3$d, username='%4$s', password='%5$s'}",
|
||||||
"host='" + host + '\'' +
|
scheme, host, port, username, password);
|
||||||
", port=" + port +
|
|
||||||
", username='" + username + '\'' +
|
|
||||||
", password='" + password + '\'' +
|
|
||||||
'}';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue