| Index: src/org/adblockplus/brazil/SSLConnectionHandler.java |
| diff --git a/src/org/adblockplus/brazil/SSLConnectionHandler.java b/src/org/adblockplus/brazil/SSLConnectionHandler.java |
| index e6324be3609dd72a165e23a4ddbaba1b2288a1d6..4a3ee7c4e7ec087693297d19853c3169ca3fcfd5 100644 |
| --- a/src/org/adblockplus/brazil/SSLConnectionHandler.java |
| +++ b/src/org/adblockplus/brazil/SSLConnectionHandler.java |
| @@ -46,8 +46,8 @@ import sunlabs.brazil.util.MatchString; |
| * |
| * </dl> |
| * |
| - * A sample set of configuration parameters illustrating how to use this |
| - * handler follows: |
| + * A sample set of configuration parameters illustrating how to use this handler |
| + * follows: |
| * |
| * <pre> |
| * handler=https |
| @@ -63,12 +63,14 @@ import sunlabs.brazil.util.MatchString; |
| public class SSLConnectionHandler extends BaseRequestHandler |
| { |
| @Override |
| - public boolean respond(Request request) throws IOException |
| + public boolean respond(final Request request) throws IOException |
| { |
| if (!request.method.equals("CONNECT")) |
| + { |
| return false; |
| + } |
| - request.log(Server.LOG_LOG, prefix, "SSL connection to " + request.url); |
| + request.log(Server.LOG_LOG, this.prefix, "SSL connection to " + request.url); |
| String host = null; |
| int port = 0; |
| @@ -76,18 +78,18 @@ public class SSLConnectionHandler extends BaseRequestHandler |
| Socket serverSocket; |
| try |
| { |
| - if (proxyHost != null) |
| + if (this.proxyHost != null) |
| { |
| - host = proxyHost; |
| - port = proxyPort; |
| - if (auth != null) |
| + host = this.proxyHost; |
| + port = this.proxyPort; |
| + if (this.auth != null) |
| { |
| - request.headers.add("Proxy-Authorization", auth); |
| + request.headers.add("Proxy-Authorization", this.auth); |
| } |
| } |
| else |
| { |
| - int c = request.url.indexOf(':'); |
| + final int c = request.url.indexOf(':'); |
| host = request.url.substring(0, c); |
| port = Integer.parseInt(request.url.substring(c + 1)); |
| } |
| @@ -97,7 +99,7 @@ public class SSLConnectionHandler extends BaseRequestHandler |
| serverSocket.setKeepAlive(true); |
| serverSocket.connect(new InetSocketAddress(host, port)); |
| } |
| - catch (Exception e) |
| + catch (final Exception e) |
| { |
| request.sendError(500, "SSL connection failure"); |
| return true; |
| @@ -105,10 +107,10 @@ public class SSLConnectionHandler extends BaseRequestHandler |
| try |
| { |
| - if (proxyHost != null) |
| + if (this.proxyHost != null) |
| { |
| // Forward request to upstream proxy |
| - OutputStream out = serverSocket.getOutputStream(); |
| + final OutputStream out = serverSocket.getOutputStream(); |
| out.write((request.method + " " + request.url + " " + request.protocol + "\r\n").getBytes()); |
| request.headers.print(out); |
| out.write("\r\n".getBytes()); |
| @@ -117,14 +119,14 @@ public class SSLConnectionHandler extends BaseRequestHandler |
| else |
| { |
| // Send response to client |
| - OutputStream out = request.sock.getOutputStream(); |
| + final OutputStream out = request.sock.getOutputStream(); |
| out.write((request.protocol + " 200 Connection established\r\n\r\n").getBytes()); |
| out.flush(); |
| } |
| // Start bi-directional data transfer |
| - ConnectionHandler client = new ConnectionHandler(request.sock, serverSocket); |
| - ConnectionHandler server = new ConnectionHandler(serverSocket, request.sock); |
| + final ConnectionHandler client = new ConnectionHandler(request.sock, serverSocket); |
| + final ConnectionHandler server = new ConnectionHandler(serverSocket, request.sock); |
| client.start(); |
| server.start(); |
| @@ -132,44 +134,44 @@ public class SSLConnectionHandler extends BaseRequestHandler |
| client.join(); |
| server.join(); |
| } |
| - catch (InterruptedException e) |
| + catch (final InterruptedException e) |
| { |
| - request.log(Server.LOG_ERROR, prefix, "Data exchange error: " + e.getMessage()); |
| + request.log(Server.LOG_ERROR, this.prefix, "Data exchange error: " + e.getMessage()); |
| } |
| // Close connection |
| serverSocket.close(); |
| - request.log(Server.LOG_LOG, prefix, "SSL connection closed"); |
| + request.log(Server.LOG_LOG, this.prefix, "SSL connection closed"); |
| return true; |
| } |
| private class ConnectionHandler extends Thread |
| { |
| - private InputStream in; |
| - private OutputStream out; |
| + private final InputStream in; |
| + private final OutputStream out; |
| - ConnectionHandler(Socket sin, Socket sout) throws IOException |
| + ConnectionHandler(final Socket sin, final Socket sout) throws IOException |
| { |
| - in = sin.getInputStream(); |
| - out = sout.getOutputStream(); |
| + this.in = sin.getInputStream(); |
| + this.out = sout.getOutputStream(); |
| } |
| @Override |
| public void run() |
| { |
| - byte[] buf = new byte[4096]; |
| + final byte[] buf = new byte[4096]; |
| int count; |
| try |
| { |
| - while ((count = in.read(buf, 0, buf.length)) != -1) |
| + while ((count = this.in.read(buf, 0, buf.length)) != -1) |
| { |
| - out.write(buf, 0, count); |
| + this.out.write(buf, 0, count); |
| } |
| - out.flush(); |
| + this.out.flush(); |
| } |
| - catch (IOException e) |
| + catch (final IOException e) |
| { |
| e.printStackTrace(); |
| } |