hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r230903 - in /jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl: ContentInputBuffer.java HttpConnectionProcessor.java
Date Mon, 08 Aug 2005 21:46:26 GMT
Author: olegk
Date: Mon Aug  8 14:46:21 2005
New Revision: 230903

URL: http://svn.apache.org/viewcvs?rev=230903&view=rev
Log:
Added a wrapper class for the Coyote request input buffer 

Added:
    jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/ContentInputBuffer.java
  (with props)
Modified:
    jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/HttpConnectionProcessor.java

Added: jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/ContentInputBuffer.java
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/ContentInputBuffer.java?rev=230903&view=auto
==============================================================================
--- jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/ContentInputBuffer.java
(added)
+++ jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/ContentInputBuffer.java
Mon Aug  8 14:46:21 2005
@@ -0,0 +1,72 @@
+/*
+ * $HeadURL$
+ * $Revision$
+ * $Date$
+ *
+ * ====================================================================
+ *
+ *  Copyright 1999-2004 The Apache Software Foundation
+ *
+ *  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.
+ * ====================================================================
+ *
+ * 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.coyote.impl;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.apache.coyote.InputBuffer;
+import org.apache.coyote.Request;
+import org.apache.http.HttpEntity;
+import org.apache.tomcat.util.buf.ByteChunk;
+
+/**
+ * <p>
+ * </p>
+ * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
+ *
+ * @version $Revision$
+ */
+public class ContentInputBuffer implements InputBuffer {
+
+    private final HttpEntity entity;
+    private final byte[] buffer = new byte[1024];
+    
+    public ContentInputBuffer(final HttpEntity entity) {
+        super();
+        if (entity == null) {
+            throw new IllegalArgumentException("HTTP entity may not be null");
+        }
+        this.entity = entity;
+    }
+
+    public int doRead(final ByteChunk chunk, final Request request) throws IOException {
+    	if (chunk == null) {
+    		throw new IllegalArgumentException("Byte chunk may not be null");
+    	}
+    	InputStream instream = this.entity.getContent();
+    	int l = instream.read(this.buffer);
+    	if (l != -1) {
+    		chunk.setBytes(this.buffer, 0, l);
+    	}
+    	return l;
+    }
+        
+}

Propchange: jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/ContentInputBuffer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/ContentInputBuffer.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/ContentInputBuffer.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/ContentInputBuffer.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/HttpConnectionProcessor.java
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/HttpConnectionProcessor.java?rev=230903&r1=230902&r2=230903&view=diff
==============================================================================
--- jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/HttpConnectionProcessor.java
(original)
+++ jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/HttpConnectionProcessor.java
Mon Aug  8 14:46:21 2005
@@ -46,6 +46,8 @@
 import org.apache.coyote.Response;
 import org.apache.http.ConnectionClosedException;
 import org.apache.http.Header;
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpEntityEnclosingRequest;
 import org.apache.http.HttpException;
 import org.apache.http.HttpMutableResponse;
 import org.apache.http.HttpRequest;
@@ -259,6 +261,14 @@
         Header[] headers = httpreq.getAllHeaders();
         for (Header header: headers) {
         	this.coyotereq.getMimeHeaders().addValue(header.getName()).setString(header.getValue());
+        }
+        
+        // Create the input buffer
+        if (this.httpreq instanceof HttpEntityEnclosingRequest) {
+        	HttpEntity entity = ((HttpEntityEnclosingRequest)this.httpreq).getEntity();
+        	if (entity != null) {
+        		this.coyotereq.setInputBuffer(new ContentInputBuffer(entity));
+        	}
         }
     }
         



Mime
View raw message