Return-Path: Delivered-To: apmail-xml-cocoon-cvs-archive@xml.apache.org Received: (qmail 30173 invoked by uid 500); 18 Feb 2002 14:51:28 -0000 Mailing-List: contact cocoon-cvs-help@xml.apache.org; run by ezmlm Precedence: bulk Reply-To: cocoon-dev@xml.apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list cocoon-cvs@xml.apache.org Received: (qmail 30143 invoked by uid 500); 18 Feb 2002 14:51:28 -0000 Delivered-To: apmail-xml-cocoon2-cvs@apache.org Date: 18 Feb 2002 14:51:27 -0000 Message-ID: <20020218145127.6024.qmail@icarus.apache.org> From: cziegeler@apache.org To: xml-cocoon2-cvs@apache.org Subject: cvs commit: xml-cocoon2/src/java/org/apache/cocoon/components/source URLSource.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N cziegeler 02/02/18 06:51:27 Modified: src/java/org/apache/cocoon/components/source URLSource.java Log: Fixed indenting Revision Changes Path 1.9 +48 -48 xml-cocoon2/src/java/org/apache/cocoon/components/source/URLSource.java Index: URLSource.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/source/URLSource.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- URLSource.java 13 Feb 2002 13:26:33 -0000 1.8 +++ URLSource.java 18 Feb 2002 14:51:27 -0000 1.9 @@ -91,7 +91,7 @@ * Description of a source which is described by an URL. * * @author Carsten Ziegeler - * @version CVS $Id: URLSource.java,v 1.8 2002/02/13 13:26:33 cziegeler Exp $ + * @version CVS $Id: URLSource.java,v 1.9 2002/02/18 14:51:27 cziegeler Exp $ */ public class URLSource implements ModifiableSource { @@ -249,57 +249,57 @@ String userInfo = this.getUserInfo(); if (this.url.getProtocol().startsWith("http") && userInfo != null) { this.connection.setRequestProperty("Authorization","Basic "+SourceUtil.encodeBASE64(userInfo)); - } - if (this.followRedirects == false && this.connection instanceof HttpURLConnection) { - ((HttpURLConnection)connection).setInstanceFollowRedirects(false); - } - // do a post operation - if (this.connection instanceof HttpURLConnection - && this.postParameters != null) { - StringBuffer buffer = new StringBuffer(2000); - String key; - Iterator i = postParameters.getParameterNames(); - Iterator values; - String value; - boolean first = true; - while ( i.hasNext() ) { - key = (String)i.next(); - values = this.postParameters.getParameterValues(key); - while (values.hasNext() == true) { - value = SourceUtil.encode((String)values.next()); - if (first == false) buffer.append('&'); - first = false; - buffer.append(key.toString()); - buffer.append('='); - buffer.append(value); - } } - HttpURLConnection httpCon = (HttpURLConnection)connection; - httpCon.setDoInput(true); - - if (buffer.length() > 1) { // only post if we have parameters - String postString = buffer.toString(); - httpCon.setRequestMethod("POST"); // this is POST - httpCon.setDoOutput(true); - httpCon.setRequestProperty("Content-type", "application/x-www-form-urlencoded"); - - // A content-length header must be contained in a POST request - httpCon.setRequestProperty("Content-length", Integer.toString(postString.length())); - java.io.OutputStream out = new java.io.BufferedOutputStream(httpCon.getOutputStream()); - out.write(postString.getBytes()); - out.close(); + if (this.followRedirects == false && this.connection instanceof HttpURLConnection) { + ((HttpURLConnection)connection).setInstanceFollowRedirects(false); } - if ("text/html".equals(httpCon.getContentType()) == true) { - this.isHTMLContent = true; + // do a post operation + if (this.connection instanceof HttpURLConnection + && this.postParameters != null) { + StringBuffer buffer = new StringBuffer(2000); + String key; + Iterator i = postParameters.getParameterNames(); + Iterator values; + String value; + boolean first = true; + while ( i.hasNext() ) { + key = (String)i.next(); + values = this.postParameters.getParameterValues(key); + while (values.hasNext() == true) { + value = SourceUtil.encode((String)values.next()); + if (first == false) buffer.append('&'); + first = false; + buffer.append(key.toString()); + buffer.append('='); + buffer.append(value); + } + } + HttpURLConnection httpCon = (HttpURLConnection)connection; + httpCon.setDoInput(true); + + if (buffer.length() > 1) { // only post if we have parameters + String postString = buffer.toString(); + httpCon.setRequestMethod("POST"); // this is POST + httpCon.setDoOutput(true); + httpCon.setRequestProperty("Content-type", "application/x-www-form-urlencoded"); + + // A content-length header must be contained in a POST request + httpCon.setRequestProperty("Content-length", Integer.toString(postString.length())); + java.io.OutputStream out = new java.io.BufferedOutputStream(httpCon.getOutputStream()); + out.write(postString.getBytes()); + out.close(); + } + if ("text/html".equals(httpCon.getContentType()) == true) { + this.isHTMLContent = true; + } + input = httpCon.getInputStream(); + this.connection = null; // make sure a new connection is created next time + return input; } - input = httpCon.getInputStream(); - this.connection = null; // make sure a new connection is created next time - return input; } - } - if ("text/html".equals(this.connection.getContentType()) == true) { - this.isHTMLContent = true; - } + if ("text/html".equals(this.connection.getContentType()) == true) { + this.isHTMLContent = true; + } input = this.connection.getInputStream(); this.connection = null; // make sure a new connection is created next time } ---------------------------------------------------------------------- In case of troubles, e-mail: webmaster@xml.apache.org To unsubscribe, e-mail: cocoon-cvs-unsubscribe@xml.apache.org For additional commands, e-mail: cocoon-cvs-help@xml.apache.org