cziegeler 2003/08/21 05:54:20
Modified: . status.xml src/blocks/proxy/java/org/apache/cocoon/generation WebServiceProxyGenerator.java Log: <action dev="CZ" type="add" fixes-bug="21399" due-to="Peter Ross" due-to-email="[EMAIL PROTECTED]"> Applying patch for processing http.nonProxyHosts in WebServiceProxyGenerator. </action> Revision Changes Path 1.129 +6 -3 cocoon-2.1/status.xml Index: status.xml =================================================================== RCS file: /home/cvs/cocoon-2.1/status.xml,v retrieving revision 1.128 retrieving revision 1.129 diff -u -r1.128 -r1.129 --- status.xml 20 Aug 2003 17:29:07 -0000 1.128 +++ status.xml 21 Aug 2003 12:54:20 -0000 1.129 @@ -189,6 +189,9 @@ <changes> <release version="@version@" date="@date@"> + <action dev="CZ" type="add" fixes-bug="21399" due-to="Peter Ross" due-to-email="[EMAIL PROTECTED]"> + Applying patch for processing http.nonProxyHosts in WebServiceProxyGenerator. + </action> <action dev="JH" type="fix" fixes-bug="22574" due-to="Neil Bacon" due-to-email="[EMAIL PROTECTED]"> POI block: fixed formula support. If no ValueType attribute is set on <gmr:Cell/>, the cell content will be interpreted as formula. @@ -301,12 +304,12 @@ Added delete capabilities to the SourceWritingTransformer. </action> <action dev="GR" type="add" fixes-bug="21881" due-to="Guido Casper" - due-to-email="[EMAIL PROTECTED]"> + due-to-email="[EMAIL PROTECTED]"> Add a defaultContentType parameter to StreamGenerator, to comply with misbehaving clients. </action> <action dev="GR" type="add" fixes-bug="21778" due-to="Guido Casper" - due-to-email="[EMAIL PROTECTED]"> + due-to-email="[EMAIL PROTECTED]"> Add a new set of WebDAV samples, with the capability of serving WebDAV content straight from Cocoon. </action> 1.2 +45 -2 cocoon-2.1/src/blocks/proxy/java/org/apache/cocoon/generation/WebServiceProxyGenerator.java Index: WebServiceProxyGenerator.java =================================================================== RCS file: /home/cvs/cocoon-2.1/src/blocks/proxy/java/org/apache/cocoon/generation/WebServiceProxyGenerator.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- WebServiceProxyGenerator.java 5 Jul 2003 14:46:13 -0000 1.1 +++ WebServiceProxyGenerator.java 21 Aug 2003 12:54:20 -0000 1.2 @@ -67,9 +67,11 @@ import org.apache.commons.httpclient.URIException; import org.apache.commons.httpclient.methods.GetMethod; import org.apache.commons.httpclient.methods.PostMethod; +import org.apache.commons.lang.StringUtils; import org.apache.excalibur.source.Source; import org.apache.excalibur.source.SourceException; import org.apache.excalibur.xml.sax.SAXParser; +import org.apache.regexp.RE; import org.xml.sax.InputSource; import org.xml.sax.SAXException; @@ -78,6 +80,7 @@ import java.util.ArrayList; import java.util.Enumeration; import java.util.Map; +import java.util.StringTokenizer; /** * @@ -263,6 +266,8 @@ * Create one per client session. */ protected HttpClient getHttpClient() throws ProcessingException { + URI uri = null; + String host = null; Request request = ObjectModelHelper.getRequest(objectModel); Session session = request.getSession(true); HttpClient httpClient = null; @@ -277,12 +282,50 @@ } try { - config.setHost(new URI(this.source)); + uri = new URI(this.source); + host = uri.getHost(); + config.setHost(uri); } catch (URIException ex) { throw new ProcessingException("URI format error: " + ex, ex); } - if (System.getProperty("http.proxyHost") != null) { + // Check the http.nonProxyHosts to see whether or not the current + // host needs to be served through the proxy server. + boolean proxiableHost = true; + String nonProxyHosts = System.getProperty("http.nonProxyHosts"); + if (nonProxyHosts != null) + { + StringTokenizer tok = new StringTokenizer(nonProxyHosts, "|"); + + while (tok.hasMoreTokens()) { + String nonProxiableHost = tok.nextToken().trim(); + + // XXX is there any other characters that need to be + // escaped? + nonProxiableHost = StringUtils.replace(nonProxiableHost, ".", "\\."); + nonProxiableHost = StringUtils.replace(nonProxiableHost, "*", ".*"); + + // XXX do we want .example.com to match + // computer.example.com? it seems to be a very common + // idiom for the nonProxyHosts, in that case then we want + // to change "^" to "^.*" + RE re = null; + try { + re = new RE("^" + nonProxiableHost + "$"); + } + catch (Exception ex) { + throw new ProcessingException("Regex syntax error: " + ex, ex); + } + + if (re.match(host)) + { + proxiableHost = false; + break; + } + } + } + + if (proxiableHost && System.getProperty("http.proxyHost") != null) { String proxyHost = System.getProperty("http.proxyHost"); int proxyPort = Integer.parseInt(System.getProperty("http.proxyPort")); config.setProxy(proxyHost, proxyPort);