/* this belongs to the WebRaveler package */ package webraveler.proxy; import java.io.*; import java.net.*; import webraveler.http.HTTPMessage; import webraveler.http.HTTPResponse; /** * The proxy client for Web Raveler that forwards requests * to the server and sends responses back to Web Raveler * * @author The Web Raveler Development Squad * @version 1.0 */ public class ProxyClient { /* variables */ Socket server; Socket client; webraveler.http.HTTPRequest request; /* constructors */ /** * @param request an HTTPRequest object containing the request from Raveler */ public ProxyClient(webraveler.http.HTTPRequest request){ this.request = request; } /* methods */ /** * Sends the request to the server and gets the response * * @return an HTTPResponse object containing the response from the server */ public HTTPResponse getResponse() throws IOException { //System.out.println("ProxyClient: Getting remote host response."); InputStream in; OutputStream out; server = new Socket(request.remoteHost(),request.remotePort()); server.setSoTimeout(60*1000); in = server.getInputStream(); out = server.getOutputStream(); //quick fix for URLs with no trailing "/" after the server root if ( request.uriString().indexOf("/",7) == -1 ) { request.setUriString( request.uriString() + "/" ); }//if request.write(out); return new HTTPResponse(in); } }//class ProxyClient