public final class DelegatingWebConnection extends Object implements com.gargoylesoftware.htmlunit.WebConnection
WebConnection
that allows delegating to various
WebConnection
implementations.
For example, if you host your JavaScript on the domain code.jquery.com
,
you might want to use the following.
WebClient webClient = new WebClient(); MockMvc mockMvc = ... MockMvcWebConnection mockConnection = new MockMvcWebConnection(mockMvc); mockConnection.setWebClient(webClient); WebRequestMatcher cdnMatcher = new UrlRegexRequestMatcher(".*?//code.jquery.com/.*"); WebConnection httpConnection = new HttpWebConnection(webClient); WebConnection webConnection = new DelegatingWebConnection(mockConnection, new DelegateWebConnection(cdnMatcher, httpConnection)); webClient.setWebConnection(webConnection); WebClient webClient = new WebClient(); webClient.setWebConnection(webConnection);
Modifier and Type | Class and Description |
---|---|
static class |
DelegatingWebConnection.DelegateWebConnection |
Constructor and Description |
---|
DelegatingWebConnection(com.gargoylesoftware.htmlunit.WebConnection defaultConnection,
DelegatingWebConnection.DelegateWebConnection... connections) |
DelegatingWebConnection(com.gargoylesoftware.htmlunit.WebConnection defaultConnection,
List<DelegatingWebConnection.DelegateWebConnection> connections) |
Modifier and Type | Method and Description |
---|---|
com.gargoylesoftware.htmlunit.WebResponse |
getResponse(com.gargoylesoftware.htmlunit.WebRequest request) |
public DelegatingWebConnection(com.gargoylesoftware.htmlunit.WebConnection defaultConnection, List<DelegatingWebConnection.DelegateWebConnection> connections)
public DelegatingWebConnection(com.gargoylesoftware.htmlunit.WebConnection defaultConnection, DelegatingWebConnection.DelegateWebConnection... connections)
public com.gargoylesoftware.htmlunit.WebResponse getResponse(com.gargoylesoftware.htmlunit.WebRequest request) throws IOException
getResponse
in interface com.gargoylesoftware.htmlunit.WebConnection
IOException