geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xuhaih...@apache.org
Subject svn commit: r1182256 - in /geronimo/bundles/trunk/commons-httpclient: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/commons/ src/main/java/org/apache/commons/httpclient/ src/main/java/org/apache/...
Date Wed, 12 Oct 2011 08:24:04 GMT
Author: xuhaihong
Date: Wed Oct 12 08:24:04 2011
New Revision: 1182256

URL: http://svn.apache.org/viewvc?rev=1182256&view=rev
Log:
Add commons-httpclient 3.1 bundle for including a security fix

Added:
    geronimo/bundles/trunk/commons-httpclient/   (with props)
    geronimo/bundles/trunk/commons-httpclient/LICENSE
    geronimo/bundles/trunk/commons-httpclient/NOTICE
    geronimo/bundles/trunk/commons-httpclient/pom.xml
    geronimo/bundles/trunk/commons-httpclient/src/   (with props)
    geronimo/bundles/trunk/commons-httpclient/src/main/   (with props)
    geronimo/bundles/trunk/commons-httpclient/src/main/java/   (with props)
    geronimo/bundles/trunk/commons-httpclient/src/main/java/org/   (with props)
    geronimo/bundles/trunk/commons-httpclient/src/main/java/org/apache/   (with props)
    geronimo/bundles/trunk/commons-httpclient/src/main/java/org/apache/commons/   (with props)
    geronimo/bundles/trunk/commons-httpclient/src/main/java/org/apache/commons/httpclient/
  (with props)
    geronimo/bundles/trunk/commons-httpclient/src/main/java/org/apache/commons/httpclient/HttpParser.java
    geronimo/bundles/trunk/commons-httpclient/src/main/java/org/apache/commons/httpclient/params/
  (with props)
    geronimo/bundles/trunk/commons-httpclient/src/main/java/org/apache/commons/httpclient/params/HttpConnectionParams.java

Propchange: geronimo/bundles/trunk/commons-httpclient/
------------------------------------------------------------------------------
    bugtraq:number = true

Added: geronimo/bundles/trunk/commons-httpclient/LICENSE
URL: http://svn.apache.org/viewvc/geronimo/bundles/trunk/commons-httpclient/LICENSE?rev=1182256&view=auto
==============================================================================
--- geronimo/bundles/trunk/commons-httpclient/LICENSE (added)
+++ geronimo/bundles/trunk/commons-httpclient/LICENSE Wed Oct 12 08:24:04 2011
@@ -0,0 +1,202 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed 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.

Added: geronimo/bundles/trunk/commons-httpclient/NOTICE
URL: http://svn.apache.org/viewvc/geronimo/bundles/trunk/commons-httpclient/NOTICE?rev=1182256&view=auto
==============================================================================
--- geronimo/bundles/trunk/commons-httpclient/NOTICE (added)
+++ geronimo/bundles/trunk/commons-httpclient/NOTICE Wed Oct 12 08:24:04 2011
@@ -0,0 +1,6 @@
+Apache Geronimo 
+Copyright 2003-2009 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+

Added: geronimo/bundles/trunk/commons-httpclient/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/bundles/trunk/commons-httpclient/pom.xml?rev=1182256&view=auto
==============================================================================
--- geronimo/bundles/trunk/commons-httpclient/pom.xml (added)
+++ geronimo/bundles/trunk/commons-httpclient/pom.xml Wed Oct 12 08:24:04 2011
@@ -0,0 +1,79 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+    <!--
+
+        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.
+    -->
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.geronimo.bundles</groupId>
+        <artifactId>bundles-parent</artifactId>
+        <version>1.0</version>
+    </parent>
+
+    <groupId>org.apache.geronimo.bundles</groupId>
+    <artifactId>${pkgArtifactId}</artifactId>
+    <version>3.1_1-SNAPSHOT</version>
+    <packaging>bundle</packaging>
+    <name>Apache Geronimo Bundles: ${pkgArtifactId}-${pkgVersion}</name>
+    <description>
+        This bundle simply wraps ${pkgArtifactId}-${pkgVersion}.jar.
+    </description>
+
+    <scm>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/geronimo/bundles/trunk/commons-httpclient</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/geronimo/bundles/trunk/commons-httpclient</developerConnection>
+        <url>http://svn.apache.org/viewvc/geronimo/bundles/trunk/commons-httpclient</url>
+    </scm>
+
+    <properties>
+        <pkgGroupId>commons-httpclient</pkgGroupId>
+        <pkgArtifactId>commons-httpclient</pkgArtifactId>
+        <pkgVersion>3.1</pkgVersion>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>${pkgGroupId}</groupId>
+            <artifactId>${pkgArtifactId}</artifactId>
+            <version>${pkgVersion}</version>
+            <optional>true</optional>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <configuration>
+                    <instructions>
+                        <Export-Package>org.apache.commons.httpclient*;version=${pkgVersion}</Export-Package>
+                        <Import-Package>!org.apache.commons.httpclient*,org.apache.commons.logging*;version="[1.1,2)",*</Import-Package>
+                        <!--<_versionpolicy>[$(version;==;$(@)),$(version;+;$(@)))</_versionpolicy>-->
+                        <Include-Resource>
+                           {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,
+                        </Include-Resource>  
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+</project>

Propchange: geronimo/bundles/trunk/commons-httpclient/src/
------------------------------------------------------------------------------
    bugtraq:number = true

Propchange: geronimo/bundles/trunk/commons-httpclient/src/main/
------------------------------------------------------------------------------
    bugtraq:number = true

Propchange: geronimo/bundles/trunk/commons-httpclient/src/main/java/
------------------------------------------------------------------------------
    bugtraq:number = true

Propchange: geronimo/bundles/trunk/commons-httpclient/src/main/java/org/
------------------------------------------------------------------------------
    bugtraq:number = true

Propchange: geronimo/bundles/trunk/commons-httpclient/src/main/java/org/apache/
------------------------------------------------------------------------------
    bugtraq:number = true

Propchange: geronimo/bundles/trunk/commons-httpclient/src/main/java/org/apache/commons/
------------------------------------------------------------------------------
    bugtraq:number = true

Propchange: geronimo/bundles/trunk/commons-httpclient/src/main/java/org/apache/commons/httpclient/
------------------------------------------------------------------------------
    bugtraq:number = true

Added: 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=1182256&view=auto
==============================================================================
--- geronimo/bundles/trunk/commons-httpclient/src/main/java/org/apache/commons/httpclient/HttpParser.java
(added)
+++ geronimo/bundles/trunk/commons-httpclient/src/main/java/org/apache/commons/httpclient/HttpParser.java
Wed Oct 12 08:24:04 2011
@@ -0,0 +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
+ * <http://www.apache.org/>.
+ *
+ */
+
+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 <a href="mailto:oleg@ural.ru">Oleg Kalnichevski</a>
+ * 
+ * @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 <tt>"\n"</tt> 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, <code>null</code> 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 <tt>"\n"</tt> 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, <code>null</code> 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 <tt>"\n"</tt> 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, <code>null</code> 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/params/
------------------------------------------------------------------------------
    bugtraq:number = true

Added: 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=1182256&view=auto
==============================================================================
--- geronimo/bundles/trunk/commons-httpclient/src/main/java/org/apache/commons/httpclient/params/HttpConnectionParams.java
(added)
+++ geronimo/bundles/trunk/commons-httpclient/src/main/java/org/apache/commons/httpclient/params/HttpConnectionParams.java
Wed Oct 12 08:24:04 2011
@@ -0,0 +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
+ * <http://www.apache.org/>.
+ *
+ */
+
+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 <a href="mailto:oleg@ural.ru">Oleg Kalnichevski</a>
+ * 
+ * @version $Revision: 480424 $
+ * 
+ * @since 3.0
+ */
+public class HttpConnectionParams extends DefaultHttpParams {
+
+    /**
+     * Defines the default socket timeout (<tt>SO_TIMEOUT</tt>) 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}. 
+     * <p>
+     * This parameter expects a value of type {@link Integer}.
+     * </p>
+     * @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. 
+     * <p>
+     * This parameter expects a value of type {@link Boolean}.
+     * </p>
+     * @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.
+     * <p>
+     * This parameter expects a value of type {@link Integer}.
+     * </p>
+     * @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.  
+     * <p>
+     * This parameter expects a value of type {@link Integer}.
+     * </p>
+     * @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 <tt>0</tt> implies that the option is
disabled.
+     * Value <tt>-1</tt> implies that the JRE default is used. The setting only
affects 
+     * socket close.  
+     * <p>
+     * This parameter expects a value of type {@link Integer}.
+     * </p>
+     * @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.
+     * <p>
+     * This parameter expects a value of type {@link Integer}.
+     * </p>
+     */
+    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. 
+     * <p>
+     * This parameter expects a value of type {@link Boolean}.
+     * </p>
+     */
+    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.
+     * <p>
+     * This parameter expects a value of type {@link Integer}.
+     * </p>
+     */
+    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.
+     * <p>
+     * This parameter expects a value of type {@link Integer}.
+     * </p>
+     */
+    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 (<tt>SO_TIMEOUT</tt>) 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 (<tt>SO_TIMEOUT</tt>) 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 <tt>true</tt> if the Nagle's algorithm is to NOT be used
+     *   (that is enable TCP_NODELAY), <tt>false</tt> otherwise.
+     */
+    public void setTcpNoDelay(boolean value) {
+        setBooleanParameter(TCP_NODELAY, value);
+    }
+
+    /**
+     * Tests if Nagle's algorithm is to be used.  
+     *
+     * @return <tt>true</tt> if the Nagle's algorithm is to NOT be used
+     *   (that is enable TCP_NODELAY), <tt>false</tt> 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 <tt>0</tt> implies that the option
is 
+     * disabled. Value <tt>-1</tt> 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 <tt>0</tt> implies that the option is 
+     * disabled. Value <tt>-1</tt> 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 <tt>true</tt> if stale connection check is to be used, 
+     *   <tt>false</tt> 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 <tt>true</tt> if stale connection check is to be used, 
+     *   <tt>false</tt> otherwise.
+     */
+    public void setStaleCheckingEnabled(boolean value) {
+        setBooleanParameter(STALE_CONNECTION_CHECK, value);
+    }
+}



Mime
View raw message