From scm-return-47450-apmail-geronimo-scm-archive=geronimo.apache.org@geronimo.apache.org Wed Oct 12 08:40:16 2011 Return-Path: X-Original-To: apmail-geronimo-scm-archive@www.apache.org Delivered-To: apmail-geronimo-scm-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id BC14471CC for ; Wed, 12 Oct 2011 08:40:16 +0000 (UTC) Received: (qmail 98678 invoked by uid 500); 12 Oct 2011 08:40:12 -0000 Delivered-To: apmail-geronimo-scm-archive@geronimo.apache.org Received: (qmail 98537 invoked by uid 500); 12 Oct 2011 08:40:02 -0000 Mailing-List: contact scm-help@geronimo.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: dev@geronimo.apache.org List-Id: Delivered-To: mailing list scm@geronimo.apache.org Received: (qmail 98404 invoked by uid 99); 12 Oct 2011 08:39:57 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 12 Oct 2011 08:39:57 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 12 Oct 2011 08:39:53 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 8F6C62388900; Wed, 12 Oct 2011 08:39:33 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1182263 - in /geronimo/bundles/trunk/commons-httpclient: pom.xml src/main/java/org/apache/commons/httpclient/HttpParser.java src/main/java/org/apache/commons/httpclient/params/HttpConnectionParams.java Date: Wed, 12 Oct 2011 08:39:33 -0000 To: scm@geronimo.apache.org From: xuhaihong@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20111012083933.8F6C62388900@eris.apache.org> Author: xuhaihong Date: Wed Oct 12 08:39:33 2011 New Revision: 1182263 URL: http://svn.apache.org/viewvc?rev=1182263&view=rev Log: Update SVN properties Modified: geronimo/bundles/trunk/commons-httpclient/pom.xml (contents, props changed) geronimo/bundles/trunk/commons-httpclient/src/main/java/org/apache/commons/httpclient/HttpParser.java (contents, props changed) geronimo/bundles/trunk/commons-httpclient/src/main/java/org/apache/commons/httpclient/params/HttpConnectionParams.java (contents, props changed) Modified: geronimo/bundles/trunk/commons-httpclient/pom.xml URL: http://svn.apache.org/viewvc/geronimo/bundles/trunk/commons-httpclient/pom.xml?rev=1182263&r1=1182262&r2=1182263&view=diff ============================================================================== --- geronimo/bundles/trunk/commons-httpclient/pom.xml (original) +++ geronimo/bundles/trunk/commons-httpclient/pom.xml Wed Oct 12 08:39:33 2011 @@ -1,79 +1,79 @@ - - - - - 4.0.0 - - - org.apache.geronimo.bundles - bundles-parent - 1.0 - - - org.apache.geronimo.bundles - ${pkgArtifactId} - 3.1_1-SNAPSHOT - bundle - Apache Geronimo Bundles: ${pkgArtifactId}-${pkgVersion} - - This bundle simply wraps ${pkgArtifactId}-${pkgVersion}.jar. - - - - scm:svn:http://svn.apache.org/repos/asf/geronimo/bundles/trunk/commons-httpclient - scm:svn:https://svn.apache.org/repos/asf/geronimo/bundles/trunk/commons-httpclient - http://svn.apache.org/viewvc/geronimo/bundles/trunk/commons-httpclient - - - - commons-httpclient - commons-httpclient - 3.1 - - - - - ${pkgGroupId} - ${pkgArtifactId} - ${pkgVersion} - true - - - - - - - org.apache.felix - maven-bundle-plugin - - - org.apache.commons.httpclient*;version=${pkgVersion} - !org.apache.commons.httpclient*,org.apache.commons.logging*;version="[1.1,2)",* - - - {maven-resources}, - org/apache/commons/httpclient/params/HttpConnectionParams.class=target/classes/org/apache/commons/httpclient/params/HttpConnectionParams.class, - org/apache/commons/httpclient/HttpParser.class=target/classes/org/apache/commons/httpclient/HttpParser.class, - - - - - - - + + + + + 4.0.0 + + + org.apache.geronimo.bundles + bundles-parent + 1.0 + + + org.apache.geronimo.bundles + ${pkgArtifactId} + 3.1_1-SNAPSHOT + bundle + Apache Geronimo Bundles: ${pkgArtifactId}-${pkgVersion} + + This bundle simply wraps ${pkgArtifactId}-${pkgVersion}.jar. + + + + scm:svn:http://svn.apache.org/repos/asf/geronimo/bundles/trunk/commons-httpclient + scm:svn:https://svn.apache.org/repos/asf/geronimo/bundles/trunk/commons-httpclient + http://svn.apache.org/viewvc/geronimo/bundles/trunk/commons-httpclient + + + + commons-httpclient + commons-httpclient + 3.1 + + + + + ${pkgGroupId} + ${pkgArtifactId} + ${pkgVersion} + true + + + + + + + org.apache.felix + maven-bundle-plugin + + + org.apache.commons.httpclient*;version=${pkgVersion} + !org.apache.commons.httpclient*,org.apache.commons.logging*;version="[1.1,2)",* + + + {maven-resources}, + org/apache/commons/httpclient/params/HttpConnectionParams.class=target/classes/org/apache/commons/httpclient/params/HttpConnectionParams.class, + org/apache/commons/httpclient/HttpParser.class=target/classes/org/apache/commons/httpclient/HttpParser.class, + + + + + + + Propchange: geronimo/bundles/trunk/commons-httpclient/pom.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: geronimo/bundles/trunk/commons-httpclient/pom.xml ------------------------------------------------------------------------------ svn:keywords = Date Author Id Revision HeadURL Propchange: geronimo/bundles/trunk/commons-httpclient/pom.xml ------------------------------------------------------------------------------ svn:mime-type = text/xml Modified: geronimo/bundles/trunk/commons-httpclient/src/main/java/org/apache/commons/httpclient/HttpParser.java URL: http://svn.apache.org/viewvc/geronimo/bundles/trunk/commons-httpclient/src/main/java/org/apache/commons/httpclient/HttpParser.java?rev=1182263&r1=1182262&r2=1182263&view=diff ============================================================================== --- geronimo/bundles/trunk/commons-httpclient/src/main/java/org/apache/commons/httpclient/HttpParser.java (original) +++ geronimo/bundles/trunk/commons-httpclient/src/main/java/org/apache/commons/httpclient/HttpParser.java Wed Oct 12 08:39:33 2011 @@ -1,265 +1,265 @@ -/* - * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//httpclient/src/java/org/apache/commons/httpclient/HttpParser.java,v 1.13 2005/01/11 13:57:06 oglueck Exp $ - * $Revision: 533405 $ - * $Date: 2007-04-29 02:19:29 +0800 (Sun, 29 Apr 2007) $ - * - * ==================================================================== - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * . - * - */ - -package org.apache.commons.httpclient; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.ArrayList; - -import org.apache.commons.httpclient.params.HttpConnectionParams; -import org.apache.commons.httpclient.util.EncodingUtil; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * A utility class for parsing http header values according to - * RFC-2616 Section 4 and 19.3. - * - * @author Michael Becke - * @author Oleg Kalnichevski - * - * @since 2.0beta1 - */ -public class HttpParser { - - /** Log object for this class. */ - private static final Log LOG = LogFactory.getLog(HttpParser.class); - - private static int MAX_HEADER_COUNT = Integer.getInteger(HttpConnectionParams.MAX_HEADER_COUNT, -1); - - private static int MAX_LINE_LENGTH = Integer.getInteger(HttpConnectionParams.MAX_LINE_LENGTH , -1); - - /** - * Constructor for HttpParser. - */ - private HttpParser() { } - - public static byte[] readRawLine(InputStream inputStream) throws IOException { - return readRawLine(inputStream, MAX_LINE_LENGTH); - } - - /** - * Return byte array from an (unchunked) input stream. - * Stop reading when "\n" terminator encountered - * If the stream ends before the line terminator is found, - * the last part of the string will still be returned. - * If no input data available, null is returned. - * - * @param inputStream the stream to read from - * - * @throws IOException if an I/O problem occurs - * @return a byte array from the stream - */ - public static byte[] readRawLine(InputStream inputStream, int maxLineLength) throws IOException { - LOG.trace("enter HttpParser.readRawLine()"); - - ByteArrayOutputStream buf = new ByteArrayOutputStream(); - int ch; - int count = 0; - while ((ch = inputStream.read()) >= 0) { - if (maxLineLength > 0 && count >= maxLineLength) { - throw new IOException("Maximum line length limit [" + maxLineLength + "] exceeded"); - } - buf.write(ch); - if (ch == '\n') { // be tolerant (RFC-2616 Section 19.3) - break; - } - count ++; - } - if (buf.size() == 0) { - return null; - } - return buf.toByteArray(); - } - - public static String readLine(InputStream inputStream, String charset) throws IOException { - return readLine(inputStream, charset, MAX_LINE_LENGTH); - } - - /** - * Read up to "\n" from an (unchunked) input stream. - * If the stream ends before the line terminator is found, - * the last part of the string will still be returned. - * If no input data available, null is returned. - * - * @param inputStream the stream to read from - * @param charset charset of HTTP protocol elements - * - * @throws IOException if an I/O problem occurs - * @return a line from the stream - * - * @since 3.0 - */ - public static String readLine(InputStream inputStream, String charset, int maxLineLength) throws IOException { - LOG.trace("enter HttpParser.readLine(InputStream, String)"); - byte[] rawdata = readRawLine(inputStream, maxLineLength); - if (rawdata == null) { - return null; - } - // strip CR and LF from the end - int len = rawdata.length; - int offset = 0; - if (len > 0) { - if (rawdata[len - 1] == '\n') { - offset++; - if (len > 1) { - if (rawdata[len - 2] == '\r') { - offset++; - } - } - } - } - final String result = - EncodingUtil.getString(rawdata, 0, len - offset, charset); - if (Wire.HEADER_WIRE.enabled()) { - String logoutput = result; - if (offset == 2) - logoutput = result + "\r\n"; - else if (offset == 1) - logoutput = result + "\n"; - Wire.HEADER_WIRE.input(logoutput); - } - return result; - } - - /** - * Read up to "\n" from an (unchunked) input stream. - * If the stream ends before the line terminator is found, - * the last part of the string will still be returned. - * If no input data available, null is returned - * - * @param inputStream the stream to read from - * - * @throws IOException if an I/O problem occurs - * @return a line from the stream - * - * @deprecated use #readLine(InputStream, String) - */ - - public static String readLine(InputStream inputStream) throws IOException { - LOG.trace("enter HttpParser.readLine(InputStream)"); - return readLine(inputStream, "US-ASCII", MAX_LINE_LENGTH); - } - - public static Header[] parseHeaders(InputStream is, String charset) throws IOException, HttpException { - LOG.trace("enter HeaderParser.parseHeaders(InputStream, String)"); - return parseHeaders(is, charset, MAX_HEADER_COUNT, MAX_LINE_LENGTH); - } - - /** - * Parses headers from the given stream. Headers with the same name are not - * combined. - * - * @param is the stream to read headers from - * @param charset the charset to use for reading the data - * - * @return an array of headers in the order in which they were parsed - * - * @throws IOException if an IO error occurs while reading from the stream - * @throws HttpException if there is an error parsing a header value - * - * @since 3.0 - */ - public static Header[] parseHeaders(InputStream is, String charset, int maxHeaderCount, int maxLineLength) throws IOException, HttpException { - LOG.trace("enter HeaderParser.parseHeaders(InputStream, String, maxHeaderCount, maxLineLen)"); - - ArrayList headers = new ArrayList(); - String name = null; - StringBuffer value = null; - for (; ;) { - String line = HttpParser.readLine(is, charset, maxLineLength); - if ((line == null) || (line.trim().length() < 1)) { - break; - } - - // Parse the header name and value - // Check for folded headers first - // Detect LWS-char see HTTP/1.0 or HTTP/1.1 Section 2.2 - // discussion on folded headers - if ((line.charAt(0) == ' ') || (line.charAt(0) == '\t')) { - // we have continuation folded header - // so append value - if (value != null) { - value.append(' '); - value.append(line.trim()); - } - } else { - // make sure we save the previous name,value pair if present - if (name != null) { - headers.add(new Header(name, value.toString())); - } - - if (maxHeaderCount > 0 && headers.size() > maxHeaderCount) { - throw new IOException("Maximum header count [" + maxHeaderCount + "] exceeded"); - } - - // Otherwise we should have normal HTTP header line - // Parse the header name and value - int colon = line.indexOf(":"); - if (colon < 0) { - throw new ProtocolException("Unable to parse header: " + line); - } - name = line.substring(0, colon).trim(); - value = new StringBuffer(line.substring(colon + 1).trim()); - } - - } - - // make sure we save the last name,value pair if present - if (name != null) { - headers.add(new Header(name, value.toString())); - } - - if (maxHeaderCount > 0 && headers.size() > maxHeaderCount) { - throw new IOException("Maximum header count [" + maxHeaderCount + "] exceeded"); - } - return (Header[]) headers.toArray(new Header[headers.size()]); - } - - /** - * Parses headers from the given stream. Headers with the same name are not - * combined. - * - * @param is the stream to read headers from - * - * @return an array of headers in the order in which they were parsed - * - * @throws IOException if an IO error occurs while reading from the stream - * @throws HttpException if there is an error parsing a header value - * - * @deprecated use #parseHeaders(InputStream, String) - */ - public static Header[] parseHeaders(InputStream is) throws IOException, HttpException { - LOG.trace("enter HeaderParser.parseHeaders(InputStream, String)"); - return parseHeaders(is, "US-ASCII", MAX_HEADER_COUNT, MAX_LINE_LENGTH); - } -} +/* + * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//httpclient/src/java/org/apache/commons/httpclient/HttpParser.java,v 1.13 2005/01/11 13:57:06 oglueck Exp $ + * $Revision$ + * $Date$ + * + * ==================================================================== + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . + * + */ + +package org.apache.commons.httpclient; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; + +import org.apache.commons.httpclient.params.HttpConnectionParams; +import org.apache.commons.httpclient.util.EncodingUtil; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * A utility class for parsing http header values according to + * RFC-2616 Section 4 and 19.3. + * + * @author Michael Becke + * @author Oleg Kalnichevski + * + * @since 2.0beta1 + */ +public class HttpParser { + + /** Log object for this class. */ + private static final Log LOG = LogFactory.getLog(HttpParser.class); + + private static int MAX_HEADER_COUNT = Integer.getInteger(HttpConnectionParams.MAX_HEADER_COUNT, -1); + + private static int MAX_LINE_LENGTH = Integer.getInteger(HttpConnectionParams.MAX_LINE_LENGTH , -1); + + /** + * Constructor for HttpParser. + */ + private HttpParser() { } + + public static byte[] readRawLine(InputStream inputStream) throws IOException { + return readRawLine(inputStream, MAX_LINE_LENGTH); + } + + /** + * Return byte array from an (unchunked) input stream. + * Stop reading when "\n" terminator encountered + * If the stream ends before the line terminator is found, + * the last part of the string will still be returned. + * If no input data available, null is returned. + * + * @param inputStream the stream to read from + * + * @throws IOException if an I/O problem occurs + * @return a byte array from the stream + */ + public static byte[] readRawLine(InputStream inputStream, int maxLineLength) throws IOException { + LOG.trace("enter HttpParser.readRawLine()"); + + ByteArrayOutputStream buf = new ByteArrayOutputStream(); + int ch; + int count = 0; + while ((ch = inputStream.read()) >= 0) { + if (maxLineLength > 0 && count >= maxLineLength) { + throw new IOException("Maximum line length limit [" + maxLineLength + "] exceeded"); + } + buf.write(ch); + if (ch == '\n') { // be tolerant (RFC-2616 Section 19.3) + break; + } + count ++; + } + if (buf.size() == 0) { + return null; + } + return buf.toByteArray(); + } + + public static String readLine(InputStream inputStream, String charset) throws IOException { + return readLine(inputStream, charset, MAX_LINE_LENGTH); + } + + /** + * Read up to "\n" from an (unchunked) input stream. + * If the stream ends before the line terminator is found, + * the last part of the string will still be returned. + * If no input data available, null is returned. + * + * @param inputStream the stream to read from + * @param charset charset of HTTP protocol elements + * + * @throws IOException if an I/O problem occurs + * @return a line from the stream + * + * @since 3.0 + */ + public static String readLine(InputStream inputStream, String charset, int maxLineLength) throws IOException { + LOG.trace("enter HttpParser.readLine(InputStream, String)"); + byte[] rawdata = readRawLine(inputStream, maxLineLength); + if (rawdata == null) { + return null; + } + // strip CR and LF from the end + int len = rawdata.length; + int offset = 0; + if (len > 0) { + if (rawdata[len - 1] == '\n') { + offset++; + if (len > 1) { + if (rawdata[len - 2] == '\r') { + offset++; + } + } + } + } + final String result = + EncodingUtil.getString(rawdata, 0, len - offset, charset); + if (Wire.HEADER_WIRE.enabled()) { + String logoutput = result; + if (offset == 2) + logoutput = result + "\r\n"; + else if (offset == 1) + logoutput = result + "\n"; + Wire.HEADER_WIRE.input(logoutput); + } + return result; + } + + /** + * Read up to "\n" from an (unchunked) input stream. + * If the stream ends before the line terminator is found, + * the last part of the string will still be returned. + * If no input data available, null is returned + * + * @param inputStream the stream to read from + * + * @throws IOException if an I/O problem occurs + * @return a line from the stream + * + * @deprecated use #readLine(InputStream, String) + */ + + public static String readLine(InputStream inputStream) throws IOException { + LOG.trace("enter HttpParser.readLine(InputStream)"); + return readLine(inputStream, "US-ASCII", MAX_LINE_LENGTH); + } + + public static Header[] parseHeaders(InputStream is, String charset) throws IOException, HttpException { + LOG.trace("enter HeaderParser.parseHeaders(InputStream, String)"); + return parseHeaders(is, charset, MAX_HEADER_COUNT, MAX_LINE_LENGTH); + } + + /** + * Parses headers from the given stream. Headers with the same name are not + * combined. + * + * @param is the stream to read headers from + * @param charset the charset to use for reading the data + * + * @return an array of headers in the order in which they were parsed + * + * @throws IOException if an IO error occurs while reading from the stream + * @throws HttpException if there is an error parsing a header value + * + * @since 3.0 + */ + public static Header[] parseHeaders(InputStream is, String charset, int maxHeaderCount, int maxLineLength) throws IOException, HttpException { + LOG.trace("enter HeaderParser.parseHeaders(InputStream, String, maxHeaderCount, maxLineLen)"); + + ArrayList headers = new ArrayList(); + String name = null; + StringBuffer value = null; + for (; ;) { + String line = HttpParser.readLine(is, charset, maxLineLength); + if ((line == null) || (line.trim().length() < 1)) { + break; + } + + // Parse the header name and value + // Check for folded headers first + // Detect LWS-char see HTTP/1.0 or HTTP/1.1 Section 2.2 + // discussion on folded headers + if ((line.charAt(0) == ' ') || (line.charAt(0) == '\t')) { + // we have continuation folded header + // so append value + if (value != null) { + value.append(' '); + value.append(line.trim()); + } + } else { + // make sure we save the previous name,value pair if present + if (name != null) { + headers.add(new Header(name, value.toString())); + } + + if (maxHeaderCount > 0 && headers.size() > maxHeaderCount) { + throw new IOException("Maximum header count [" + maxHeaderCount + "] exceeded"); + } + + // Otherwise we should have normal HTTP header line + // Parse the header name and value + int colon = line.indexOf(":"); + if (colon < 0) { + throw new ProtocolException("Unable to parse header: " + line); + } + name = line.substring(0, colon).trim(); + value = new StringBuffer(line.substring(colon + 1).trim()); + } + + } + + // make sure we save the last name,value pair if present + if (name != null) { + headers.add(new Header(name, value.toString())); + } + + if (maxHeaderCount > 0 && headers.size() > maxHeaderCount) { + throw new IOException("Maximum header count [" + maxHeaderCount + "] exceeded"); + } + return (Header[]) headers.toArray(new Header[headers.size()]); + } + + /** + * Parses headers from the given stream. Headers with the same name are not + * combined. + * + * @param is the stream to read headers from + * + * @return an array of headers in the order in which they were parsed + * + * @throws IOException if an IO error occurs while reading from the stream + * @throws HttpException if there is an error parsing a header value + * + * @deprecated use #parseHeaders(InputStream, String) + */ + public static Header[] parseHeaders(InputStream is) throws IOException, HttpException { + LOG.trace("enter HeaderParser.parseHeaders(InputStream, String)"); + return parseHeaders(is, "US-ASCII", MAX_HEADER_COUNT, MAX_LINE_LENGTH); + } +} Propchange: geronimo/bundles/trunk/commons-httpclient/src/main/java/org/apache/commons/httpclient/HttpParser.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: geronimo/bundles/trunk/commons-httpclient/src/main/java/org/apache/commons/httpclient/HttpParser.java ------------------------------------------------------------------------------ svn:keywords = Date Author Id Revision HeadURL Propchange: geronimo/bundles/trunk/commons-httpclient/src/main/java/org/apache/commons/httpclient/HttpParser.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Modified: geronimo/bundles/trunk/commons-httpclient/src/main/java/org/apache/commons/httpclient/params/HttpConnectionParams.java URL: http://svn.apache.org/viewvc/geronimo/bundles/trunk/commons-httpclient/src/main/java/org/apache/commons/httpclient/params/HttpConnectionParams.java?rev=1182263&r1=1182262&r2=1182263&view=diff ============================================================================== --- geronimo/bundles/trunk/commons-httpclient/src/main/java/org/apache/commons/httpclient/params/HttpConnectionParams.java (original) +++ geronimo/bundles/trunk/commons-httpclient/src/main/java/org/apache/commons/httpclient/params/HttpConnectionParams.java Wed Oct 12 08:39:33 2011 @@ -1,327 +1,327 @@ -/* - * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//httpclient/src/java/org/apache/commons/httpclient/params/HttpConnectionParams.java,v 1.6 2004/09/15 20:32:21 olegk Exp $ - * $Revision: 480424 $ - * $Date: 2006-11-29 13:56:49 +0800 (Wed, 29 Nov 2006) $ - * - * ==================================================================== - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * . - * - */ - -package org.apache.commons.httpclient.params; - -/** - * This class represents a collection of HTTP protocol parameters applicable to - * {@link org.apache.commons.httpclient.HttpConnection HTTP connections}. - * Protocol parameters may be linked together to form a hierarchy. If a particular - * parameter value has not been explicitly defined in the collection itself, its - * value will be drawn from the parent collection of parameters. - * - * @author Oleg Kalnichevski - * - * @version $Revision: 480424 $ - * - * @since 3.0 - */ -public class HttpConnectionParams extends DefaultHttpParams { - - /** - * Defines the default socket timeout (SO_TIMEOUT) in milliseconds which is the - * timeout for waiting for data. A timeout value of zero is interpreted as an infinite - * timeout. This value is used when no socket timeout is set in the - * {@link HttpMethodParams HTTP method parameters}. - *

- * This parameter expects a value of type {@link Integer}. - *

- * @see java.net.SocketOptions#SO_TIMEOUT - */ - public static final String SO_TIMEOUT = "http.socket.timeout"; - - /** - * Determines whether Nagle's algorithm is to be used. The Nagle's algorithm - * tries to conserve bandwidth by minimizing the number of segments that are - * sent. When applications wish to decrease network latency and increase - * performance, they can disable Nagle's algorithm (that is enable TCP_NODELAY). - * Data will be sent earlier, at the cost of an increase in bandwidth consumption. - *

- * This parameter expects a value of type {@link Boolean}. - *

- * @see java.net.SocketOptions#TCP_NODELAY - */ - public static final String TCP_NODELAY = "http.tcp.nodelay"; - - /** - * Determines a hint the size of the underlying buffers used by the platform - * for outgoing network I/O. This value is a suggestion to the kernel from - * the application about the size of buffers to use for the data to be sent - * over the socket. - *

- * This parameter expects a value of type {@link Integer}. - *

- * @see java.net.SocketOptions#SO_SNDBUF - */ - public static final String SO_SNDBUF = "http.socket.sendbuffer"; - - /** - * Determines a hint the size of the underlying buffers used by the platform - * for incoming network I/O. This value is a suggestion to the kernel from - * the application about the size of buffers to use for the data to be received - * over the socket. - *

- * This parameter expects a value of type {@link Integer}. - *

- * @see java.net.SocketOptions#SO_RCVBUF - */ - public static final String SO_RCVBUF = "http.socket.receivebuffer"; - - /** - * Sets SO_LINGER with the specified linger time in seconds. The maximum timeout - * value is platform specific. Value 0 implies that the option is disabled. - * Value -1 implies that the JRE default is used. The setting only affects - * socket close. - *

- * This parameter expects a value of type {@link Integer}. - *

- * @see java.net.SocketOptions#SO_LINGER - */ - public static final String SO_LINGER = "http.socket.linger"; - - /** - * Determines the timeout until a connection is etablished. A value of zero - * means the timeout is not used. The default value is zero. - *

- * This parameter expects a value of type {@link Integer}. - *

- */ - public static final String CONNECTION_TIMEOUT = "http.connection.timeout"; - - /** - * Determines whether stale connection check is to be used. Disabling - * stale connection check may result in slight performance improvement - * at the risk of getting an I/O error when executing a request over a - * connection that has been closed at the server side. - *

- * This parameter expects a value of type {@link Boolean}. - *

- */ - public static final String STALE_CONNECTION_CHECK = "http.connection.stalecheck"; - - /** - * Determines the maximum line length limit. If set to a positive value, - * any HTTP line exceeding this limit will cause an IOException. A negative - * or zero value will effectively disable the check. - *

- * This parameter expects a value of type {@link Integer}. - *

- */ - public static final String MAX_LINE_LENGTH = "http.connection.max-line-length"; - - /** - * Determines the maximum HTTP header count allowed. If set to a positive - * value, the number of HTTP headers received from the data stream exceeding - * this limit will cause an IOException. A negative or zero value will - * effectively disable the check. - *

- * This parameter expects a value of type {@link Integer}. - *

- */ - public static final String MAX_HEADER_COUNT = "http.connection.max-header-count"; - - /** - * Creates a new collection of parameters with the collection returned - * by {@link #getDefaultParams()} as a parent. The collection will defer - * to its parent for a default value if a particular parameter is not - * explicitly set in the collection itself. - * - * @see #getDefaultParams() - */ - public HttpConnectionParams() { - super(); - } - - /** - * Returns the default socket timeout (SO_TIMEOUT) in milliseconds which is the - * timeout for waiting for data. A timeout value of zero is interpreted as an infinite - * timeout. This value is used when no socket timeout is set in the - * {@link HttpMethodParams HTTP method parameters}. - * - * @return timeout in milliseconds - */ - public int getSoTimeout() { - return getIntParameter(SO_TIMEOUT, 0); - } - - /** - * Sets the default socket timeout (SO_TIMEOUT) in milliseconds which is the - * timeout for waiting for data. A timeout value of zero is interpreted as an infinite - * timeout. This value is used when no socket timeout is set in the - * {@link HttpMethodParams HTTP method parameters}. - * - * @param timeout Timeout in milliseconds - */ - public void setSoTimeout(int timeout) { - setIntParameter(SO_TIMEOUT, timeout); - } - - /** - * Determines whether Nagle's algorithm is to be used. The Nagle's algorithm - * tries to conserve bandwidth by minimizing the number of segments that are - * sent. When applications wish to decrease network latency and increase - * performance, they can disable Nagle's algorithm (that is enable TCP_NODELAY). - * Data will be sent earlier, at the cost of an increase in bandwidth consumption. - * - * @param value true if the Nagle's algorithm is to NOT be used - * (that is enable TCP_NODELAY), false otherwise. - */ - public void setTcpNoDelay(boolean value) { - setBooleanParameter(TCP_NODELAY, value); - } - - /** - * Tests if Nagle's algorithm is to be used. - * - * @return true if the Nagle's algorithm is to NOT be used - * (that is enable TCP_NODELAY), false otherwise. - */ - public boolean getTcpNoDelay() { - return getBooleanParameter(TCP_NODELAY, true); - } - - /** - * Returns a hint the size of the underlying buffers used by the platform for - * outgoing network I/O. This value is a suggestion to the kernel from the - * application about the size of buffers to use for the data to be sent over - * the socket. - * - * @return the hint size of the send buffer - */ - public int getSendBufferSize() { - return getIntParameter(SO_SNDBUF, -1); - } - - /** - * Sets a hint the size of the underlying buffers used by the platform for - * outgoing network I/O. This value is a suggestion to the kernel from the - * application about the size of buffers to use for the data to be sent over - * the socket. - * - * @param size the hint size of the send buffer - */ - public void setSendBufferSize(int size) { - setIntParameter(SO_SNDBUF, size); - } - - /** - * Returns a hint the size of the underlying buffers used by the platform - * for incoming network I/O. This value is a suggestion to the kernel from - * the application about the size of buffers to use for the data to be received - * over the socket. - * - * @return the hint size of the send buffer - */ - public int getReceiveBufferSize() { - return getIntParameter(SO_RCVBUF, -1); - } - - /** - * Sets a hint the size of the underlying buffers used by the platform - * for incoming network I/O. This value is a suggestion to the kernel from - * the application about the size of buffers to use for the data to be received - * over the socket. - * - * @param size the hint size of the send buffer - */ - public void setReceiveBufferSize(int size) { - setIntParameter(SO_RCVBUF, size); - } - - /** - * Returns linger-on-close timeout. Value 0 implies that the option is - * disabled. Value -1 implies that the JRE default is used. - * - * @return the linger-on-close timeout - */ - public int getLinger() { - return getIntParameter(SO_LINGER, -1); - } - - /** - * Returns linger-on-close timeout. This option disables/enables immediate return - * from a close() of a TCP Socket. Enabling this option with a non-zero Integer - * timeout means that a close() will block pending the transmission and - * acknowledgement of all data written to the peer, at which point the socket is - * closed gracefully. Value 0 implies that the option is - * disabled. Value -1 implies that the JRE default is used. - * - * @param value the linger-on-close timeout - */ - public void setLinger(int value) { - setIntParameter(SO_LINGER, value); - } - - /** - * Returns the timeout until a connection is etablished. A value of zero - * means the timeout is not used. The default value is zero. - * - * @return timeout in milliseconds. - */ - public int getConnectionTimeout() { - return getIntParameter(CONNECTION_TIMEOUT, 0); - } - - /** - * Sets the timeout until a connection is etablished. A value of zero - * means the timeout is not used. The default value is zero. - * - * @param timeout Timeout in milliseconds. - */ - public void setConnectionTimeout(int timeout) { - setIntParameter(CONNECTION_TIMEOUT, timeout); - } - - /** - * Tests whether stale connection check is to be used. Disabling - * stale connection check may result in slight performance improvement - * at the risk of getting an I/O error when executing a request over a - * connection that has been closed at the server side. - * - * @return true if stale connection check is to be used, - * false otherwise. - */ - public boolean isStaleCheckingEnabled() { - return getBooleanParameter(STALE_CONNECTION_CHECK, true); - } - - /** - * Defines whether stale connection check is to be used. Disabling - * stale connection check may result in slight performance improvement - * at the risk of getting an I/O error when executing a request over a - * connection that has been closed at the server side. - * - * @param value true if stale connection check is to be used, - * false otherwise. - */ - public void setStaleCheckingEnabled(boolean value) { - setBooleanParameter(STALE_CONNECTION_CHECK, value); - } -} +/* + * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//httpclient/src/java/org/apache/commons/httpclient/params/HttpConnectionParams.java,v 1.6 2004/09/15 20:32:21 olegk Exp $ + * $Revision$ + * $Date$ + * + * ==================================================================== + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . + * + */ + +package org.apache.commons.httpclient.params; + +/** + * This class represents a collection of HTTP protocol parameters applicable to + * {@link org.apache.commons.httpclient.HttpConnection HTTP connections}. + * Protocol parameters may be linked together to form a hierarchy. If a particular + * parameter value has not been explicitly defined in the collection itself, its + * value will be drawn from the parent collection of parameters. + * + * @author Oleg Kalnichevski + * + * @version $Revision$ + * + * @since 3.0 + */ +public class HttpConnectionParams extends DefaultHttpParams { + + /** + * Defines the default socket timeout (SO_TIMEOUT) in milliseconds which is the + * timeout for waiting for data. A timeout value of zero is interpreted as an infinite + * timeout. This value is used when no socket timeout is set in the + * {@link HttpMethodParams HTTP method parameters}. + *

+ * This parameter expects a value of type {@link Integer}. + *

+ * @see java.net.SocketOptions#SO_TIMEOUT + */ + public static final String SO_TIMEOUT = "http.socket.timeout"; + + /** + * Determines whether Nagle's algorithm is to be used. The Nagle's algorithm + * tries to conserve bandwidth by minimizing the number of segments that are + * sent. When applications wish to decrease network latency and increase + * performance, they can disable Nagle's algorithm (that is enable TCP_NODELAY). + * Data will be sent earlier, at the cost of an increase in bandwidth consumption. + *

+ * This parameter expects a value of type {@link Boolean}. + *

+ * @see java.net.SocketOptions#TCP_NODELAY + */ + public static final String TCP_NODELAY = "http.tcp.nodelay"; + + /** + * Determines a hint the size of the underlying buffers used by the platform + * for outgoing network I/O. This value is a suggestion to the kernel from + * the application about the size of buffers to use for the data to be sent + * over the socket. + *

+ * This parameter expects a value of type {@link Integer}. + *

+ * @see java.net.SocketOptions#SO_SNDBUF + */ + public static final String SO_SNDBUF = "http.socket.sendbuffer"; + + /** + * Determines a hint the size of the underlying buffers used by the platform + * for incoming network I/O. This value is a suggestion to the kernel from + * the application about the size of buffers to use for the data to be received + * over the socket. + *

+ * This parameter expects a value of type {@link Integer}. + *

+ * @see java.net.SocketOptions#SO_RCVBUF + */ + public static final String SO_RCVBUF = "http.socket.receivebuffer"; + + /** + * Sets SO_LINGER with the specified linger time in seconds. The maximum timeout + * value is platform specific. Value 0 implies that the option is disabled. + * Value -1 implies that the JRE default is used. The setting only affects + * socket close. + *

+ * This parameter expects a value of type {@link Integer}. + *

+ * @see java.net.SocketOptions#SO_LINGER + */ + public static final String SO_LINGER = "http.socket.linger"; + + /** + * Determines the timeout until a connection is etablished. A value of zero + * means the timeout is not used. The default value is zero. + *

+ * This parameter expects a value of type {@link Integer}. + *

+ */ + public static final String CONNECTION_TIMEOUT = "http.connection.timeout"; + + /** + * Determines whether stale connection check is to be used. Disabling + * stale connection check may result in slight performance improvement + * at the risk of getting an I/O error when executing a request over a + * connection that has been closed at the server side. + *

+ * This parameter expects a value of type {@link Boolean}. + *

+ */ + public static final String STALE_CONNECTION_CHECK = "http.connection.stalecheck"; + + /** + * Determines the maximum line length limit. If set to a positive value, + * any HTTP line exceeding this limit will cause an IOException. A negative + * or zero value will effectively disable the check. + *

+ * This parameter expects a value of type {@link Integer}. + *

+ */ + public static final String MAX_LINE_LENGTH = "http.connection.max-line-length"; + + /** + * Determines the maximum HTTP header count allowed. If set to a positive + * value, the number of HTTP headers received from the data stream exceeding + * this limit will cause an IOException. A negative or zero value will + * effectively disable the check. + *

+ * This parameter expects a value of type {@link Integer}. + *

+ */ + public static final String MAX_HEADER_COUNT = "http.connection.max-header-count"; + + /** + * Creates a new collection of parameters with the collection returned + * by {@link #getDefaultParams()} as a parent. The collection will defer + * to its parent for a default value if a particular parameter is not + * explicitly set in the collection itself. + * + * @see #getDefaultParams() + */ + public HttpConnectionParams() { + super(); + } + + /** + * Returns the default socket timeout (SO_TIMEOUT) in milliseconds which is the + * timeout for waiting for data. A timeout value of zero is interpreted as an infinite + * timeout. This value is used when no socket timeout is set in the + * {@link HttpMethodParams HTTP method parameters}. + * + * @return timeout in milliseconds + */ + public int getSoTimeout() { + return getIntParameter(SO_TIMEOUT, 0); + } + + /** + * Sets the default socket timeout (SO_TIMEOUT) in milliseconds which is the + * timeout for waiting for data. A timeout value of zero is interpreted as an infinite + * timeout. This value is used when no socket timeout is set in the + * {@link HttpMethodParams HTTP method parameters}. + * + * @param timeout Timeout in milliseconds + */ + public void setSoTimeout(int timeout) { + setIntParameter(SO_TIMEOUT, timeout); + } + + /** + * Determines whether Nagle's algorithm is to be used. The Nagle's algorithm + * tries to conserve bandwidth by minimizing the number of segments that are + * sent. When applications wish to decrease network latency and increase + * performance, they can disable Nagle's algorithm (that is enable TCP_NODELAY). + * Data will be sent earlier, at the cost of an increase in bandwidth consumption. + * + * @param value true if the Nagle's algorithm is to NOT be used + * (that is enable TCP_NODELAY), false otherwise. + */ + public void setTcpNoDelay(boolean value) { + setBooleanParameter(TCP_NODELAY, value); + } + + /** + * Tests if Nagle's algorithm is to be used. + * + * @return true if the Nagle's algorithm is to NOT be used + * (that is enable TCP_NODELAY), false otherwise. + */ + public boolean getTcpNoDelay() { + return getBooleanParameter(TCP_NODELAY, true); + } + + /** + * Returns a hint the size of the underlying buffers used by the platform for + * outgoing network I/O. This value is a suggestion to the kernel from the + * application about the size of buffers to use for the data to be sent over + * the socket. + * + * @return the hint size of the send buffer + */ + public int getSendBufferSize() { + return getIntParameter(SO_SNDBUF, -1); + } + + /** + * Sets a hint the size of the underlying buffers used by the platform for + * outgoing network I/O. This value is a suggestion to the kernel from the + * application about the size of buffers to use for the data to be sent over + * the socket. + * + * @param size the hint size of the send buffer + */ + public void setSendBufferSize(int size) { + setIntParameter(SO_SNDBUF, size); + } + + /** + * Returns a hint the size of the underlying buffers used by the platform + * for incoming network I/O. This value is a suggestion to the kernel from + * the application about the size of buffers to use for the data to be received + * over the socket. + * + * @return the hint size of the send buffer + */ + public int getReceiveBufferSize() { + return getIntParameter(SO_RCVBUF, -1); + } + + /** + * Sets a hint the size of the underlying buffers used by the platform + * for incoming network I/O. This value is a suggestion to the kernel from + * the application about the size of buffers to use for the data to be received + * over the socket. + * + * @param size the hint size of the send buffer + */ + public void setReceiveBufferSize(int size) { + setIntParameter(SO_RCVBUF, size); + } + + /** + * Returns linger-on-close timeout. Value 0 implies that the option is + * disabled. Value -1 implies that the JRE default is used. + * + * @return the linger-on-close timeout + */ + public int getLinger() { + return getIntParameter(SO_LINGER, -1); + } + + /** + * Returns linger-on-close timeout. This option disables/enables immediate return + * from a close() of a TCP Socket. Enabling this option with a non-zero Integer + * timeout means that a close() will block pending the transmission and + * acknowledgement of all data written to the peer, at which point the socket is + * closed gracefully. Value 0 implies that the option is + * disabled. Value -1 implies that the JRE default is used. + * + * @param value the linger-on-close timeout + */ + public void setLinger(int value) { + setIntParameter(SO_LINGER, value); + } + + /** + * Returns the timeout until a connection is etablished. A value of zero + * means the timeout is not used. The default value is zero. + * + * @return timeout in milliseconds. + */ + public int getConnectionTimeout() { + return getIntParameter(CONNECTION_TIMEOUT, 0); + } + + /** + * Sets the timeout until a connection is etablished. A value of zero + * means the timeout is not used. The default value is zero. + * + * @param timeout Timeout in milliseconds. + */ + public void setConnectionTimeout(int timeout) { + setIntParameter(CONNECTION_TIMEOUT, timeout); + } + + /** + * Tests whether stale connection check is to be used. Disabling + * stale connection check may result in slight performance improvement + * at the risk of getting an I/O error when executing a request over a + * connection that has been closed at the server side. + * + * @return true if stale connection check is to be used, + * false otherwise. + */ + public boolean isStaleCheckingEnabled() { + return getBooleanParameter(STALE_CONNECTION_CHECK, true); + } + + /** + * Defines whether stale connection check is to be used. Disabling + * stale connection check may result in slight performance improvement + * at the risk of getting an I/O error when executing a request over a + * connection that has been closed at the server side. + * + * @param value true if stale connection check is to be used, + * false otherwise. + */ + public void setStaleCheckingEnabled(boolean value) { + setBooleanParameter(STALE_CONNECTION_CHECK, value); + } +} Propchange: geronimo/bundles/trunk/commons-httpclient/src/main/java/org/apache/commons/httpclient/params/HttpConnectionParams.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: geronimo/bundles/trunk/commons-httpclient/src/main/java/org/apache/commons/httpclient/params/HttpConnectionParams.java ------------------------------------------------------------------------------ svn:keywords = Date Author Id Revision HeadURL Propchange: geronimo/bundles/trunk/commons-httpclient/src/main/java/org/apache/commons/httpclient/params/HttpConnectionParams.java ------------------------------------------------------------------------------ svn:mime-type = text/plain