logo       

[HtmlUnit] CVS Commit: src/xdocs: Proxy settings now respected to load ext: msg#00077

java.htmlunit.devel

Subject: [HtmlUnit] CVS Commit: src/xdocs: Proxy settings now respected to load external

Log Message:
-----------
Proxy settings now respected to load external JavaScript files (fixes bug
1460444)

Modified Files:
--------------
htmlunit/src/test/java/com/gargoylesoftware/htmlunit:
WebClientTest.java

(http://cvs.sourceforge.net/viewcvs.py/htmlunit/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/WebClientTest.java)
htmlunit/src/java/com/gargoylesoftware/htmlunit:
WebClient.java

(http://cvs.sourceforge.net/viewcvs.py/htmlunit/htmlunit/src/java/com/gargoylesoftware/htmlunit/WebClient.java)
htmlunit/src/xdocs:
changes.xml

(http://cvs.sourceforge.net/viewcvs.py/htmlunit/htmlunit/src/xdocs/changes.xml)

Revision Data
-------------
Index: WebClient.java
===================================================================
RCS file:
/cvsroot/htmlunit/htmlunit/src/java/com/gargoylesoftware/htmlunit/WebClient.java,v
retrieving revision 1.120
retrieving revision 1.121
diff -Lsrc/java/com/gargoylesoftware/htmlunit/WebClient.java
-Lsrc/java/com/gargoylesoftware/htmlunit/WebClient.java -u -d -r1.120 -r1.121
--- src/java/com/gargoylesoftware/htmlunit/WebClient.java
+++ src/java/com/gargoylesoftware/htmlunit/WebClient.java
@@ -313,15 +313,6 @@

getLog().debug("Get page for window named '" + webWindow.getName() +
"', using " + parameters);

- // If the request settings don't specify a custom proxy, use the
default client proxy...
- if( parameters.getProxyHost() == null ) {
- // ...unless the host needs to bypass the configured client proxy!
- if( ! shouldBypassProxy( parameters.getURL().getHost() ) ) {
- parameters.setProxyHost( proxyHost_ );
- parameters.setProxyPort( proxyPort_ );
- }
- }
-
final WebResponse webResponse;
final String protocol = parameters.getURL().getProtocol();
if (protocol.equals("javascript")) {
@@ -1343,6 +1334,15 @@

getLog().debug("Load response for " + url.toExternalForm());

+ // If the request settings don't specify a custom proxy, use the
default client proxy...
+ if( webRequestSettings.getProxyHost() == null ) {
+ // ...unless the host needs to bypass the configured client proxy!
+ if( ! shouldBypassProxy( webRequestSettings.getURL().getHost() ) )
{
+ webRequestSettings.setProxyHost( proxyHost_ );
+ webRequestSettings.setProxyPort( proxyPort_ );
+ }
+ }
+
//TODO: this should probably be handled inside of WebRequestSettings
and
// could cause a bug if anything above here reads the url again
final URL fixedUrl = encodeUrl(url);
Index: WebClientTest.java
===================================================================
RCS file:
/cvsroot/htmlunit/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/WebClientTest.java,v
retrieving revision 1.68
retrieving revision 1.69
diff -Lsrc/test/java/com/gargoylesoftware/htmlunit/WebClientTest.java
-Lsrc/test/java/com/gargoylesoftware/htmlunit/WebClientTest.java -u -d -r1.68
-r1.69
--- src/test/java/com/gargoylesoftware/htmlunit/WebClientTest.java
+++ src/test/java/com/gargoylesoftware/htmlunit/WebClientTest.java
@@ -1038,6 +1038,41 @@
}

/**
+ * @throws Exception If the test fails.
+ */
+ public void testProxyConfigForJS() throws Exception {
+
+ final String defaultProxyHost = "defaultProxyHost";
+ final int defaultProxyPort = 777;
+ final String html = "<html><head><title>Hello World</title>"
+ + "<script language='javascript' type='text/javascript'
src='foo.js'></script>"
+ + "</head><body></body></html>";
+ final WebClient webClient = new WebClient(
BrowserVersion.INTERNET_EXPLORER_6_0,
+ defaultProxyHost, defaultProxyPort );
+ final MockWebConnection webConnection = new
MockWebConnection(webClient);
+ webConnection.setResponse( URL_FIRST, html );
+ webConnection.setResponse(new URL(URL_FIRST, "foo.js"), "",
"text/javascript");
+ webClient.setWebConnection(webConnection);
+
+ // Make sure default proxy settings are used.
+ webClient.getPage( URL_FIRST );
+ assertEquals( defaultProxyHost,
webConnection.getLastWebRequestSettings().getProxyHost() );
+ assertEquals( defaultProxyPort,
webConnection.getLastWebRequestSettings().getProxyPort() );
+
+ // Make sure proxy bypass works with default proxy settings.
+ webClient.addHostsToProxyBypass( URL_FIRST.getHost() );
+ webClient.getPage( URL_FIRST );
+ assertEquals( null,
webConnection.getLastWebRequestSettings().getProxyHost() );
+ assertEquals( 0,
webConnection.getLastWebRequestSettings().getProxyPort() );
+
+ // Make sure we can remove proxy bypass filters.
+ webClient.removeHostsFromProxyBypass( URL_FIRST.getHost() );
+ webClient.getPage( URL_FIRST );
+ assertEquals( defaultProxyHost,
webConnection.getLastWebRequestSettings().getProxyHost() );
+ assertEquals( defaultProxyPort,
webConnection.getLastWebRequestSettings().getProxyPort() );
+ }
+
+ /**
* Test {@link WebClient#expandUrl(URL,String)} for the case where an
anchor name
* was specified.
* @throws Exception If the test fails.
Index: changes.xml
===================================================================
RCS file: /cvsroot/htmlunit/htmlunit/src/xdocs/changes.xml,v
retrieving revision 1.496
retrieving revision 1.497
diff -Lsrc/xdocs/changes.xml -Lsrc/xdocs/changes.xml -u -d -r1.496 -r1.497
--- src/xdocs/changes.xml
+++ src/xdocs/changes.xml
@@ -7,15 +7,18 @@

<body>
<release version="next">
+ <action type="update" dev="mguillem" id="1460444">
+ Proxy settings now respected to load external JavaScript files.
+ </action>
<action type="update" dev="yourgod">
HtmlCheckBoxInput.setChecked() now fires the JavaScript
onchange event.
- </action>
+ </action>
<action type="update" dev="yourgod">
Implemented window.setTimeout(function, int) and
window.setInterval(function, int)
- </action>
+ </action>
<action type="update" dev="yourgod">
HtmlOption.asText() now respects the label attribute as
browsers do.
- </action>
+ </action>
<action type="update" dev="mguillem" id="1437068">
Encode path part of urls containing illegal
characters.
</action>


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise