Skip to content

Commit

Permalink
Tuning and missing things
Browse files Browse the repository at this point in the history
  • Loading branch information
vietj committed May 26, 2016
1 parent 42b10b8 commit 6b8437f
Show file tree
Hide file tree
Showing 21 changed files with 261 additions and 189 deletions.
14 changes: 7 additions & 7 deletions src/main/asciidoc/dataobjects.adoc
Expand Up @@ -743,7 +743,7 @@ Set the protocol version.
+++
|[[proxyOptions]]`proxyOptions`|`link:dataobjects.html#ProxyOptions[ProxyOptions]`|
+++
Set proxy options for https connections via CONNECT proxy (e.g. Squid) or a SOCKS proxy.
Set proxy options for connections via CONNECT proxy (e.g. Squid) or a SOCKS proxy.
+++
|[[receiveBufferSize]]`receiveBufferSize`|`Number (int)`|
+++
Expand Down Expand Up @@ -1627,33 +1627,33 @@ Set the store as a buffer
== ProxyOptions

++++
Proxy options for a NetClient or HttpClient
Proxy options for a net client or a net client.
++++
'''

[cols=">25%,^25%,50%"]
[frame="topbot"]
|===
^|Name | Type ^| Description
|[[proxyHost]]`proxyHost`|`String`|
|[[host]]`host`|`String`|
+++
Set proxy host.
+++
|[[proxyPassword]]`proxyPassword`|`String`|
|[[password]]`password`|`String`|
+++
Set proxy password.
+++
|[[proxyPort]]`proxyPort`|`Number (int)`|
|[[port]]`port`|`Number (int)`|
+++
Set proxy port.
+++
|[[proxyType]]`proxyType`|`link:enums.html#ProxyType[ProxyType]`|
|[[type]]`type`|`link:enums.html#ProxyType[ProxyType]`|
+++
Set proxy type.

<p>ProxyType can be HTTP, SOCKS4 and SOCKS5
+++
|[[proxyUsername]]`proxyUsername`|`String`|
|[[username]]`username`|`String`|
+++
Set proxy username.
+++
Expand Down
3 changes: 1 addition & 2 deletions src/main/asciidoc/enums.adoc
Expand Up @@ -150,8 +150,7 @@ ID 14, bad timestamp
== ProxyType

++++
@author <a href="http://oss.lehmann.cx/">Alexander Lehmann</a>
The type of a TCP proxy server.
++++
'''

Expand Down
18 changes: 9 additions & 9 deletions src/main/asciidoc/java/http.adoc
Expand Up @@ -2016,32 +2016,32 @@ used with binary frames that are no split over multiple frames.

=== Using a proxy for HTTPS connections

The http client supports accessing https server via a HTTPS proxy (HTTP/1.x CONNECT method), e.g. Squid or
SOCKS4a or SOCKS5 proxy. The http proxy protocol uses HTTP/1.x but can connect to HTTP/1.x and HTTP/2 servers.
The http client supports accessing https server via an HTTPS proxy (HTTP/1.x _CONNECT_ method), e.g. Squid or
_SOCKS4a_ or _SOCKS5_ proxy. The http proxy protocol uses HTTP/1.x but can connect to HTTP/1.x and HTTP/2 servers.

The proxy can be configured in the `link:../../apidocs/io/vertx/core/http/HttpClientOptions.html[HttpClientOptions]` by setting a
`link:../../apidocs/io/vertx/core/net/ProxyOptions.html[ProxyOptions]` object containing proxy type, hostname, port and optionally username and password.

For this feature, the jar io.netty:netty-handler-proxy has to be present on the classpath.
For this feature, the jar `io.netty:netty-handler-proxy` has to be present on the classpath.

Here's an example:

[source,java]
----
HttpClientOptions options = new HttpClientOptions()
.setProxyOptions(new ProxyOptions().setProxyType(ProxyType.HTTP)
.setProxyHost("localhost").setProxyPort(3128)
.setProxyUsername("username").setProxyPassword("secret"));
.setProxyOptions(new ProxyOptions().setType(ProxyType.HTTP)
.setHost("localhost").setPort(3128)
.setUsername("username").setPassword("secret"));
HttpClient client = vertx.createHttpClient(options);
----
or using a SOCKS5 proxy

[source,java]
----
HttpClientOptions options = new HttpClientOptions()
.setProxyOptions(new ProxyOptions().setProxyType(ProxyType.SOCKS5)
.setProxyHost("localhost").setProxyPort(1080)
.setProxyUsername("username").setProxyPassword("secret"));
.setProxyOptions(new ProxyOptions().setType(ProxyType.SOCKS5)
.setHost("localhost").setPort(1080)
.setUsername("username").setPassword("secret"));
HttpClient client = vertx.createHttpClient(options);
----

Expand Down
12 changes: 6 additions & 6 deletions src/main/asciidoc/java/net.adoc
Expand Up @@ -921,24 +921,24 @@ ALPN version for the JVM running it:
-javaagent:/path/to/alpn/agent
----

=== Using a proxy for NetClient connections
=== Using a proxy for client connections

The NetClient supports configuring a HTTP/1.x CONNECT proxy or SOCKS4a or SOCKS5 proxy.
The `link:../../apidocs/io/vertx/core/net/NetClient.html[NetClient]` supports configuring an HTTP/1.x _CONNECT_ proxy or _SOCKS4a_ or _SOCKS5_ proxy.

The proxy can be configured in the `link:../../apidocs/io/vertx/core/net/NetClientOptions.html[NetClientOptions]` by setting a
`link:../../apidocs/io/vertx/core/net/ProxyOptions.html[ProxyOptions]` object containing proxy type, hostname, port and optionally username and password.

For this feature, the jar io.netty:netty-handler-proxy has to be present on the classpath.
For this feature, the jar `io.netty:netty-handler-proxy` has to be present on the classpath.

Here's an example:

[source,java]

----
NetClientOptions options = new NetClientOptions()
.setProxyOptions(new ProxyOptions().setProxyType(ProxyType.SOCKS5)
.setProxyHost("localhost").setProxyPort(1080)
.setProxyUsername("username").setProxyPassword("secret"));
.setProxyOptions(new ProxyOptions().setType(ProxyType.SOCKS5)
.setHost("localhost").setPort(1080)
.setUsername("username").setPassword("secret"));
NetClient client = vertx.createNetClient(options);
----

Expand Down
38 changes: 19 additions & 19 deletions src/main/generated/io/vertx/core/net/ProxyOptionsConverter.java
Expand Up @@ -27,36 +27,36 @@
public class ProxyOptionsConverter {

public static void fromJson(JsonObject json, ProxyOptions obj) {
if (json.getValue("proxyHost") instanceof String) {
obj.setProxyHost((String)json.getValue("proxyHost"));
if (json.getValue("host") instanceof String) {
obj.setHost((String)json.getValue("host"));
}
if (json.getValue("proxyPassword") instanceof String) {
obj.setProxyPassword((String)json.getValue("proxyPassword"));
if (json.getValue("password") instanceof String) {
obj.setPassword((String)json.getValue("password"));
}
if (json.getValue("proxyPort") instanceof Number) {
obj.setProxyPort(((Number)json.getValue("proxyPort")).intValue());
if (json.getValue("port") instanceof Number) {
obj.setPort(((Number)json.getValue("port")).intValue());
}
if (json.getValue("proxyType") instanceof String) {
obj.setProxyType(io.vertx.core.net.ProxyType.valueOf((String)json.getValue("proxyType")));
if (json.getValue("type") instanceof String) {
obj.setType(io.vertx.core.net.ProxyType.valueOf((String)json.getValue("type")));
}
if (json.getValue("proxyUsername") instanceof String) {
obj.setProxyUsername((String)json.getValue("proxyUsername"));
if (json.getValue("username") instanceof String) {
obj.setUsername((String)json.getValue("username"));
}
}

public static void toJson(ProxyOptions obj, JsonObject json) {
if (obj.getProxyHost() != null) {
json.put("proxyHost", obj.getProxyHost());
if (obj.getHost() != null) {
json.put("host", obj.getHost());
}
if (obj.getProxyPassword() != null) {
json.put("proxyPassword", obj.getProxyPassword());
if (obj.getPassword() != null) {
json.put("password", obj.getPassword());
}
json.put("proxyPort", obj.getProxyPort());
if (obj.getProxyType() != null) {
json.put("proxyType", obj.getProxyType().name());
json.put("port", obj.getPort());
if (obj.getType() != null) {
json.put("type", obj.getType().name());
}
if (obj.getProxyUsername() != null) {
json.put("proxyUsername", obj.getProxyUsername());
if (obj.getUsername() != null) {
json.put("username", obj.getUsername());
}
}
}
12 changes: 6 additions & 6 deletions src/main/java/examples/HTTPExamples.java
Expand Up @@ -703,19 +703,19 @@ public void example57(WebSocket websocket) {
public void example58(Vertx vertx) {

HttpClientOptions options = new HttpClientOptions()
.setProxyOptions(new ProxyOptions().setProxyType(ProxyType.HTTP)
.setProxyHost("localhost").setProxyPort(3128)
.setProxyUsername("username").setProxyPassword("secret"));
.setProxyOptions(new ProxyOptions().setType(ProxyType.HTTP)
.setHost("localhost").setPort(3128)
.setUsername("username").setPassword("secret"));
HttpClient client = vertx.createHttpClient(options);

}

public void example59(Vertx vertx) {

HttpClientOptions options = new HttpClientOptions()
.setProxyOptions(new ProxyOptions().setProxyType(ProxyType.SOCKS5)
.setProxyHost("localhost").setProxyPort(1080)
.setProxyUsername("username").setProxyPassword("secret"));
.setProxyOptions(new ProxyOptions().setType(ProxyType.SOCKS5)
.setHost("localhost").setPort(1080)
.setUsername("username").setPassword("secret"));
HttpClient client = vertx.createHttpClient(options);

}
Expand Down
7 changes: 3 additions & 4 deletions src/main/java/examples/NetExamples.java
Expand Up @@ -20,7 +20,6 @@
import io.vertx.core.Vertx;
import io.vertx.core.buffer.Buffer;
import io.vertx.core.http.ClientAuth;
import io.vertx.core.http.HttpClient;
import io.vertx.core.net.*;

/**
Expand Down Expand Up @@ -526,9 +525,9 @@ public void example46(Vertx vertx, JksOptions keyStoreOptions) {

public void example47(Vertx vertx) {
NetClientOptions options = new NetClientOptions()
.setProxyOptions(new ProxyOptions().setProxyType(ProxyType.SOCKS5)
.setProxyHost("localhost").setProxyPort(1080)
.setProxyUsername("username").setProxyPassword("secret"));
.setProxyOptions(new ProxyOptions().setType(ProxyType.SOCKS5)
.setHost("localhost").setPort(1080)
.setUsername("username").setPassword("secret"));
NetClient client = vertx.createNetClient(options);
}
}
6 changes: 0 additions & 6 deletions src/main/java/io/vertx/core/http/HttpClientOptions.java
Expand Up @@ -649,12 +649,6 @@ public HttpClientOptions setMetricsName(String metricsName) {
return (HttpClientOptions) super.setMetricsName(metricsName);
}

/**
* Set proxy options for https connections via CONNECT proxy (e.g. Squid) or a SOCKS proxy.
*
* @param proxyOptions proxy options object
* @return a reference to this, so the API can be used fluently
*/
public HttpClientOptions setProxyOptions(ProxyOptions proxyOptions) {
return (HttpClientOptions) super.setProxyOptions(proxyOptions);
}
Expand Down
4 changes: 0 additions & 4 deletions src/main/java/io/vertx/core/http/impl/ConnectionManager.java
Expand Up @@ -128,10 +128,6 @@ public void close() {
}

public void getConnectionForWebsocket(int port, String host, Waiter waiter) {
// if (!keepAlive && pipelining) {
// waiter.handleFailure(new IllegalStateException("Cannot have pipelining with no keep alive"));
// } else {
// }
TargetAddress address = new TargetAddress(host, port);
ConnQueue connQueue = wsQM.getConnQueue(address, HttpVersion.HTTP_1_1);
connQueue.getConnection(waiter);
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/io/vertx/core/http/package-info.java
Expand Up @@ -1575,13 +1575,13 @@
*
* === Using a proxy for HTTPS connections
*
* The http client supports accessing https server via a HTTPS proxy (HTTP/1.x CONNECT method), e.g. Squid or
* SOCKS4a or SOCKS5 proxy. The http proxy protocol uses HTTP/1.x but can connect to HTTP/1.x and HTTP/2 servers.
* The http client supports accessing https server via an HTTPS proxy (HTTP/1.x _CONNECT_ method), e.g. Squid or
* _SOCKS4a_ or _SOCKS5_ proxy. The http proxy protocol uses HTTP/1.x but can connect to HTTP/1.x and HTTP/2 servers.
*
* The proxy can be configured in the {@link io.vertx.core.http.HttpClientOptions} by setting a
* {@link io.vertx.core.net.ProxyOptions} object containing proxy type, hostname, port and optionally username and password.
*
* For this feature, the jar io.netty:netty-handler-proxy has to be present on the classpath.
* For this feature, the jar `io.netty:netty-handler-proxy` has to be present on the classpath.
*
* Here's an example:
*
Expand Down
1 change: 0 additions & 1 deletion src/main/java/io/vertx/core/net/ClientOptionsBase.java
Expand Up @@ -47,7 +47,6 @@ public abstract class ClientOptionsBase extends TCPSSLOptions {
private int connectTimeout;
private boolean trustAll;
private String metricsName;

private ProxyOptions proxyOptions;

/**
Expand Down
6 changes: 0 additions & 6 deletions src/main/java/io/vertx/core/net/NetClientOptions.java
Expand Up @@ -299,12 +299,6 @@ public NetClientOptions setLogActivity(boolean logEnabled) {
return (NetClientOptions) super.setLogActivity(logEnabled);
}

/**
* Set proxy options for connections via CONNECT proxy (e.g. Squid) or a SOCKS proxy.
*
* @param proxyOptions proxy options object
* @return a reference to this, so the API can be used fluently
*/
public NetClientOptions setProxyOptions(ProxyOptions proxyOptions) {
return (NetClientOptions) super.setProxyOptions(proxyOptions);
}
Expand Down

0 comments on commit 6b8437f

Please sign in to comment.