You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2022/07/01 08:53:06 UTC
[httpcomponents-core] branch master updated: Minor cleanup (#354)
This is an automated email from the ASF dual-hosted git repository.
olegk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/httpcomponents-core.git
The following commit(s) were added to refs/heads/master by this push:
new 96849fa3d Minor cleanup (#354)
96849fa3d is described below
commit 96849fa3d799ca7258d74e1f9b2dbd04c51cc478
Author: jkmcl <jk...@users.noreply.github.com>
AuthorDate: Fri Jul 1 16:53:02 2022 +0800
Minor cleanup (#354)
---
.../org/apache/hc/core5/reactor/SocksProxyProtocolHandler.java | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/reactor/SocksProxyProtocolHandler.java b/httpcore5/src/main/java/org/apache/hc/core5/reactor/SocksProxyProtocolHandler.java
index a66ca7c24..9521ec2d0 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/reactor/SocksProxyProtocolHandler.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/reactor/SocksProxyProtocolHandler.java
@@ -82,8 +82,6 @@ final class SocksProxyProtocolHandler implements IOEventHandler {
// a 32 byte buffer is enough for all usual SOCKS negotiations, we expand it if necessary during the processing
private ByteBuffer buffer = ByteBuffer.allocate(32);
private State state = State.SEND_AUTH;
- private int remainingResponseSize = -1;
-
SocksProxyProtocolHandler(final ProtocolIOSession ioSession, final Object attachment, final InetSocketAddress targetAddress,
final String username, final String password, final IOEventHandlerFactory eventHandlerFactory) {
this.ioSession = ioSession;
@@ -220,10 +218,10 @@ final class SocksProxyProtocolHandler implements IOEventHandler {
} else {
throw new IOException("SOCKS server returned unsupported address type: " + aType);
}
- this.remainingResponseSize = addressSize + 2;
+ final int remainingResponseSize = addressSize + 2;
this.buffer.compact();
// make sure we only read what we need to, don't read too much
- this.buffer.limit(this.remainingResponseSize);
+ this.buffer.limit(remainingResponseSize);
this.state = State.RECEIVE_ADDRESS;
// deliberate fall-through
} else {
@@ -262,13 +260,12 @@ final class SocksProxyProtocolHandler implements IOEventHandler {
this.buffer.put((byte) 0); // reserved
if (address instanceof Inet4Address) {
this.buffer.put(InetAddressUtils.IPV4);
- this.buffer.put(address.getAddress());
} else if (address instanceof Inet6Address) {
this.buffer.put(InetAddressUtils.IPV6);
- this.buffer.put(address.getAddress());
} else {
throw new IOException("Unsupported remote address class: " + address.getClass().getName());
}
+ this.buffer.put(address.getAddress());
this.buffer.putShort((short) port);
this.buffer.flip();
}