/** * Creates a web response object which represents the response to the specified web request. **/ protected WebResponse newResponse( WebRequest request, FrameSelector targetFrame ) throws MalformedURLException, IOException { Properties savedProperties = (Properties) System.getProperties().clone(); try { if (_proxyHost != null) { System.setProperty( "proxyHost", _proxyHost ); System.setProperty( "proxyPort", Integer.toString( _proxyPort ) ); } URLConnection connection = openConnection( getRequestURL( request ) ); // [ 1518901 ] enable http connect and read timeouts (needs JDK 1.5) // XXX enable for 1.7 release in 2008 // comment out if you need this and have JDK 1.5 // if (_connectTimeout>=0) connection.setConnectTimeout( _connectTimeout ); // if (_readTimeout>=0) connection.setReadTimeout( _readTimeout ); if (HttpUnitOptions.isLoggingHttpHeaders()) { String urlString = request.getURLString(); System.out.println( "\nConnecting to " + request.getURL().getHost() ); System.out.println( "Sending:: " + request.getMethod() + " " + urlString ); } sendHeaders( connection, getHeaderFields( request.getURL() ) ); sendHeaders( connection, request.getHeaderDictionary() ); request.completeRequest( connection ); return new HttpWebResponse( this, targetFrame, request, connection, getExceptionsThrownOnErrorStatus() ); } finally { System.setProperties( savedProperties ); } }
/** * Creates a web response object which represents the response to the specified web request. **/ protected WebResponse newResponse( WebRequest request, FrameSelector targetFrame ) throws MalformedURLException, IOException { Properties savedProperties = (Properties) System.getProperties().clone(); try { if (_proxyHost != null) { System.setProperty( "proxyHost", _proxyHost ); System.setProperty( "proxyPort", Integer.toString( _proxyPort ) ); } URLConnection connection = openConnection( getRequestURL( request ) ); // [ 1518901 ] enable http connect and read timeouts (needs JDK 1.5) // XXX enable for 1.7 release in 2008 // comment out if you need this and have JDK 1.5 // if (_connectTimeout>=0) connection.setConnectTimeout( _connectTimeout ); // if (_readTimeout>=0) connection.setReadTimeout( _readTimeout ); if (HttpUnitOptions.isLoggingHttpHeaders()) { String urlString = request.getURLString(); System.out.println( "\nConnecting to " + request.getURL().getHost() ); System.out.println( "Sending:: " + request.getMethod() + " " + urlString ); } sendHeaders( connection, getHeaderFields( request.getURL() ) ); sendHeaders( connection, request.getHeaderDictionary() ); request.completeRequest( connection ); return new HttpWebResponse( this, targetFrame, request, connection, getExceptionsThrownOnErrorStatus() ); } finally { System.setProperties( savedProperties ); } }
/** * Creates a web response object which represents the response to the specified web request. **/ protected WebResponse newResponse( WebRequest request, FrameSelector targetFrame ) throws MalformedURLException, IOException { Properties savedProperties = (Properties) System.getProperties().clone(); try { if (_proxyHost != null) { System.setProperty( "proxyHost", _proxyHost ); System.setProperty( "proxyPort", Integer.toString( _proxyPort ) ); } URLConnection connection = openConnection( getRequestURL( request ) ); // [ 1518901 ] enable http connect and read timeouts (needs JDK 1.5) // XXX enable for 1.7 release in 2008 // comment out if you need this and have JDK 1.5 // if (_connectTimeout>=0) connection.setConnectTimeout( _connectTimeout ); // if (_readTimeout>=0) connection.setReadTimeout( _readTimeout ); if (HttpUnitOptions.isLoggingHttpHeaders()) { String urlString = request.getURLString(); System.out.println( "\nConnecting to " + request.getURL().getHost() ); System.out.println( "Sending:: " + request.getMethod() + " " + urlString ); } sendHeaders( connection, getHeaderFields( request.getURL() ) ); sendHeaders( connection, request.getHeaderDictionary() ); request.completeRequest( connection ); return new HttpWebResponse( this, targetFrame, request, connection, getExceptionsThrownOnErrorStatus() ); } finally { System.setProperties( savedProperties ); } }