/* basicweb.ProxyServer.java
* $Id, $Date eric Exp $
* (c) COPYRIGHT MIT and INRIA, 1997.
* Please first read the full copyright statement in file COPYRIGHT.html
*
* Full of Sound and Fury...
*/
/*
The ProxyServer acts as the server side of a proxy. The client role is filled
by ProxyClient which is kicked of as a request
method by ProxyRequest.lookupMethod.
*/
package w3c.model.tools.basicweb;
import java.io.*;
import java.net.Socket;
import w3c.model.www.pep.PEPAgent;
import w3c.model.www.pep.PEPProxy;
import w3c.model.www.pep.PEPProxyClient;
import w3c.model.www.pep.altlib.ErrorContext;
import w3c.model.www.pep.altlib.HttpErrors;
import w3c.model.www.pep.altlib.HTTPException;
import w3c.model.www.pep.altlib.HttpParserException;
class ProxyServer extends BaseServer
PEPProxyClient pepClient;
ProxyServer ( intport) throwsIOException{
super(port);
pepClient = PEPProxyClient(); // for CopyBodyProxy to talk to servers
System.out.println("<!- proxy server port: " + port + " ->");
super.serve();
}
Request makeRequest ( Socketsocket, InputStreamin, OutputStreamout, PEPAgentpepAgent, ErrorContexterrorContext) {
return ProxyRequest(socket, in, null, pepAgent, errorContext, pepClient);
}
void prepPEP () throwsHttpParserException HTTPException{
pepAgent = PEPProxy(); // for talking to clients
}
void preServe ( Requestrequest) {}
public static void main ( Stringargs[]) throws IOException{
intproxyPort = 8887;
for (inti = 0 ; i < args.length ; i++)) {
if ( args[i] .equals ("-port") )) {
try {
proxyPort = Integer.parseInt(args[++i]) ;
} catch (NumberFormatExceptionex)) {
System.out.println ("invalid port number ["+args[i]+"]");
System.exit (1) ;
}
}
}
ProxyServer(proxyPort);
}