com.gargoylesoftware.htmlunit.util
Class FalsifyingWebConnection

java.lang.Object
  extended by com.gargoylesoftware.htmlunit.util.WebConnectionWrapper
      extended by com.gargoylesoftware.htmlunit.util.FalsifyingWebConnection
All Implemented Interfaces:
WebConnection

public abstract class FalsifyingWebConnection
extends WebConnectionWrapper

Extension of WebConnectionWrapper providing facility methods to deliver something else than what the wrapped connection would deliver.

Version:
$Revision: 2132 $
Author:
Marc Guillemot

Constructor Summary
FalsifyingWebConnection(WebClient webClient)
          Constructs an instance and places itself as connection of the WebClient.
FalsifyingWebConnection(WebConnection webConnection)
          Constructs a WebConnection object wrapping provided WebConnection.
 
Method Summary
protected  WebResponse deliverFromAlternateUrl(WebRequestSettings webRequestSettings, URL url)
          Delivers the content for an alternate url as if it would come from the requested one
protected  WebResponse replaceContent(WebResponse webResponse, String newContent)
          Builds a WebResponse with a new content preserving the other informations
 
Methods inherited from class com.gargoylesoftware.htmlunit.util.WebConnectionWrapper
getResponse, getState, getWebClient
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FalsifyingWebConnection

public FalsifyingWebConnection(WebConnection webConnection)
                        throws IllegalArgumentException
Constructs a WebConnection object wrapping provided WebConnection.

Parameters:
webConnection - the webConnection that does the real work
Throws:
IllegalArgumentException - if the connection is null

FalsifyingWebConnection

public FalsifyingWebConnection(WebClient webClient)
                        throws IllegalArgumentException
Constructs an instance and places itself as connection of the WebClient.

Parameters:
webClient - the WebClient which WebConnection should be wrapped
Throws:
IllegalArgumentException - if the WebClient is null
Method Detail

deliverFromAlternateUrl

protected WebResponse deliverFromAlternateUrl(WebRequestSettings webRequestSettings,
                                              URL url)
                                       throws IOException
Delivers the content for an alternate url as if it would come from the requested one

Parameters:
webRequestSettings - the original web request settings
url - the url from which the content should be retrieved
Returns:
the response
Throws:
IOException - if a problem occurred

replaceContent

protected WebResponse replaceContent(WebResponse webResponse,
                                     String newContent)
                              throws IOException
Builds a WebResponse with a new content preserving the other informations

Parameters:
webResponse - the web response to adapt
newContent - the new content to place in the response
Returns:
a web response with the new content
Throws:
IOException - if an encoding problem occurred


Copyright © 2002-2010 Gargoyle Software Inc.. All Rights Reserved.