2 // Copyright (C) 2002 Constantin Kaplinsky, Inc. All Rights Reserved.
4 // This is free software; you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation; either version 2 of the License, or
7 // (at your option) any later version.
9 // This software is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with this software; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
21 // HTTPConnectSocketFactory.java together with HTTPConnectSocket.java
22 // implement an alternate way to connect to VNC servers via one or two
23 // HTTP proxies supporting the HTTP CONNECT method.
30 class HTTPConnectSocketFactory implements SocketFactory {
32 public Socket createSocket(String host, int port, Applet applet)
35 return createSocket(host, port,
36 applet.getParameter("PROXYHOST1"),
37 applet.getParameter("PROXYPORT1"));
40 public Socket createSocket(String host, int port, String[] args)
43 return createSocket(host, port,
44 readArg(args, "PROXYHOST1"),
45 readArg(args, "PROXYPORT1"));
48 public Socket createSocket(String host, int port,
49 String proxyHost, String proxyPortStr)
53 if (proxyPortStr != null) {
55 proxyPort = Integer.parseInt(proxyPortStr);
56 } catch (NumberFormatException e) { }
59 if (proxyHost == null || proxyPort == 0) {
60 System.out.println("Incomplete parameter list for HTTPConnectSocket");
61 return new Socket(host, port);
64 System.out.println("HTTP CONNECT via proxy " + proxyHost +
65 " port " + proxyPort);
67 new HTTPConnectSocket(host, port, proxyHost, proxyPort);
72 private String readArg(String[] args, String name) {
74 for (int i = 0; i < args.length; i += 2) {
75 if (args[i].equalsIgnoreCase(name)) {
78 } catch (Exception e) {