You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2007/05/15 10:18:17 UTC

svn commit: r538089 - in /jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio: entity/ protocol/

Author: olegk
Date: Tue May 15 01:18:16 2007
New Revision: 538089

URL: http://svn.apache.org/viewvc?view=rev&rev=538089
Log:
HTTPCORE-74: BufferedContent, ContentInputStream, ContentOutputStream made public

Added:
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/entity/
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/entity/ContentBufferEntity.java   (with props)
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/entity/ContentInputStream.java
      - copied, changed from r535769, jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/ContentInputStream.java
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/entity/ContentOutputStream.java
      - copied, changed from r535769, jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/ContentOutputStream.java
Removed:
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/BufferedContent.java
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/ContentInputStream.java
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/ContentOutputStream.java
Modified:
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/BufferingHttpClientHandler.java
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/BufferingHttpServiceHandler.java
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/ThrottlingHttpServiceHandler.java

Added: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/entity/ContentBufferEntity.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/entity/ContentBufferEntity.java?view=auto&rev=538089
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/entity/ContentBufferEntity.java (added)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/entity/ContentBufferEntity.java Tue May 15 01:18:16 2007
@@ -0,0 +1,69 @@
+/*
+ * $HeadURL$
+ * $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
+ * <http://www.apache.org/>.
+ *
+ */
+
+package org.apache.http.nio.entity;
+
+import org.apache.http.Header;
+import org.apache.http.HttpEntity;
+import org.apache.http.entity.BasicHttpEntity;
+import org.apache.http.nio.util.ContentInputBuffer;
+
+public class ContentBufferEntity extends BasicHttpEntity {
+
+    /** The wrapped entity. */
+    private HttpEntity wrappedEntity;
+    
+    public ContentBufferEntity(final HttpEntity entity, final ContentInputBuffer buffer) {
+        super();
+        if (entity == null) {
+            throw new IllegalArgumentException("HTTP entity may not be null");
+        }
+        this.wrappedEntity = entity;
+        setContent(new ContentInputStream(buffer));
+    }
+
+    public boolean isChunked() {
+        return this.wrappedEntity.isChunked();
+    }
+
+    public long getContentLength() {
+        return this.wrappedEntity.getContentLength();
+    }
+
+    public Header getContentType() {
+        return this.wrappedEntity.getContentType();
+    }
+
+    public Header getContentEncoding() {
+        return this.wrappedEntity.getContentEncoding();
+    }
+    
+}

Propchange: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/entity/ContentBufferEntity.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/entity/ContentBufferEntity.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/entity/ContentBufferEntity.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/entity/ContentInputStream.java (from r535769, jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/ContentInputStream.java)
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/entity/ContentInputStream.java?view=diff&rev=538089&p1=jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/ContentInputStream.java&r1=535769&p2=jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/entity/ContentInputStream.java&r2=538089
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/ContentInputStream.java (original)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/entity/ContentInputStream.java Tue May 15 01:18:16 2007
@@ -29,14 +29,14 @@
  *
  */
 
-package org.apache.http.nio.protocol;
+package org.apache.http.nio.entity;
 
 import java.io.IOException;
 import java.io.InputStream;
 
 import org.apache.http.nio.util.ContentInputBuffer;
 
-class ContentInputStream extends InputStream {
+public class ContentInputStream extends InputStream {
 
     private final ContentInputBuffer buffer;
     

Copied: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/entity/ContentOutputStream.java (from r535769, jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/ContentOutputStream.java)
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/entity/ContentOutputStream.java?view=diff&rev=538089&p1=jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/ContentOutputStream.java&r1=535769&p2=jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/entity/ContentOutputStream.java&r2=538089
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/ContentOutputStream.java (original)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/entity/ContentOutputStream.java Tue May 15 01:18:16 2007
@@ -29,14 +29,14 @@
  *
  */
 
-package org.apache.http.nio.protocol;
+package org.apache.http.nio.entity;
 
 import java.io.IOException;
 import java.io.OutputStream;
 
 import org.apache.http.nio.util.ContentOutputBuffer;
 
-class ContentOutputStream extends OutputStream {
+public class ContentOutputStream extends OutputStream {
 
     private final ContentOutputBuffer buffer;
     

Modified: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/BufferingHttpClientHandler.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/BufferingHttpClientHandler.java?view=diff&rev=538089&r1=538088&r2=538089
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/BufferingHttpClientHandler.java (original)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/BufferingHttpClientHandler.java Tue May 15 01:18:16 2007
@@ -49,6 +49,8 @@
 import org.apache.http.nio.ContentEncoder;
 import org.apache.http.nio.NHttpClientConnection;
 import org.apache.http.nio.NHttpClientHandler;
+import org.apache.http.nio.entity.ContentBufferEntity;
+import org.apache.http.nio.entity.ContentOutputStream;
 import org.apache.http.nio.util.ContentInputBuffer;
 import org.apache.http.nio.util.ContentOutputBuffer;
 import org.apache.http.nio.util.SimpleInputBuffer;
@@ -416,7 +418,7 @@
         HttpResponse response = connState.getResponse();
         
         if (response.getEntity() != null) {
-            response.setEntity(new BufferedContent(
+            response.setEntity(new ContentBufferEntity(
                     response.getEntity(), 
                     connState.getInbuffer()));
         }

Modified: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/BufferingHttpServiceHandler.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/BufferingHttpServiceHandler.java?view=diff&rev=538089&r1=538088&r2=538089
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/BufferingHttpServiceHandler.java (original)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/BufferingHttpServiceHandler.java Tue May 15 01:18:16 2007
@@ -52,6 +52,8 @@
 import org.apache.http.nio.NHttpConnection;
 import org.apache.http.nio.NHttpServerConnection;
 import org.apache.http.nio.NHttpServiceHandler;
+import org.apache.http.nio.entity.ContentBufferEntity;
+import org.apache.http.nio.entity.ContentOutputStream;
 import org.apache.http.nio.util.ContentInputBuffer;
 import org.apache.http.nio.util.ContentOutputBuffer;
 import org.apache.http.nio.util.SimpleInputBuffer;
@@ -266,7 +268,7 @@
                 // Create a wrapper entity instead of the original one
                 HttpEntityEnclosingRequest entityReq = (HttpEntityEnclosingRequest) request;
                 if (entityReq.getEntity() != null) {
-                    entityReq.setEntity(new BufferedContent(
+                    entityReq.setEntity(new ContentBufferEntity(
                             entityReq.getEntity(), 
                             connState.getInbuffer()));
                 }

Modified: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/ThrottlingHttpServiceHandler.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/ThrottlingHttpServiceHandler.java?view=diff&rev=538089&r1=538088&r2=538089
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/ThrottlingHttpServiceHandler.java (original)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/ThrottlingHttpServiceHandler.java Tue May 15 01:18:16 2007
@@ -54,6 +54,8 @@
 import org.apache.http.nio.NHttpConnection;
 import org.apache.http.nio.NHttpServerConnection;
 import org.apache.http.nio.NHttpServiceHandler;
+import org.apache.http.nio.entity.ContentBufferEntity;
+import org.apache.http.nio.entity.ContentOutputStream;
 import org.apache.http.nio.params.HttpNIOParams;
 import org.apache.http.nio.util.ContentInputBuffer;
 import org.apache.http.nio.util.ContentOutputBuffer;
@@ -472,7 +474,7 @@
 
             // Create a wrapper entity instead of the original one
             if (entityReq.getEntity() != null) {
-                entityReq.setEntity(new BufferedContent(
+                entityReq.setEntity(new ContentBufferEntity(
                         entityReq.getEntity(), 
                         connState.getInbuffer()));
             }