/* this belongs to the WebRaveler package */ package webraveler.vurl; import java.io.*; import webraveler.http.HTTPRequest; import webraveler.http.HTTPResponse; import webraveler.proxy.ProxyClient; import webraveler.ravel.Raveler; /** * This VURL unravels a page. * * @author The Web Raveler Development Squad * @version 1.0 */ public class UnravelVURL implements VURL{ HTTPRequest unravelRequest; String uriString; /** * Constructs an UnravelVURL with the original request */ public UnravelVURL (HTTPRequest request) { unravelRequest = request; } // UnravelVURL() /** * Constructs an UnravelVURL with the url */ public UnravelVURL (String url) { this.uriString = url; unravelRequest = HTTPRequest.generateGetRequest(url); } /** * Gets the response directly from the server using the original request */ public HTTPResponse resolveVURL (String username, String query, HTTPRequest request, Raveler ravel) { System.out.println("UnravelVURL: Unraveling page '"+unravelRequest.uriString()+"'"); HTTPResponse response = null; ProxyClient proxy; proxy = new ProxyClient(unravelRequest); try { response = proxy.getResponse(); }catch(IOException ioe) { return null; } //catch /* try making an HTMLPage object to represent the content, if applicable. * also, we have to make URLs absolute, using VURLs. */ String contentType; contentType = (String) response.getHeader("content-type"); if ( contentType != null && contentType.equalsIgnoreCase("text/html")) { response.htmlPage.makeURLsAbsolute(unravelRequest,response); // System.out.println("response.entityText = "+response.entityText); }//if return response; } // resolveVURL } // class UnravelVURL