incubator-droids-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r983393 - in /incubator/droids/trunk: ./ droids-core/src/main/java/org/apache/droids/api/ droids-core/src/main/java/org/apache/droids/protocol/http/
Date Sun, 08 Aug 2010 12:00:37 GMT
Author: olegk
Date: Sun Aug  8 12:00:36 2010
New Revision: 983393

URL: http://svn.apache.org/viewvc?rev=983393&view=rev
Log:
HTTP transport improvements: DoS prevention (dealing with infinite header lines, infinite
number of HTTP headers, infinite content body); more lenient HTTP message parser

Added:
    incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/protocol/http/ContentTooLongException.java
  (with props)
    incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/protocol/http/DroidHttpEntity.java
  (with props)
    incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/protocol/http/DroidsHttpConnection.java
  (with props)
    incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/protocol/http/DroidsHttpConnectionManager.java
  (with props)
    incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/protocol/http/DroidsHttpConnectionOperator.java
  (with props)
    incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/protocol/http/LenientHttpResponseParser.java
  (with props)
Modified:
    incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/api/Worker.java
    incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/protocol/http/AdvancedHttpContentEntity.java
    incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/protocol/http/AdvancedHttpProtocol.java
    incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/protocol/http/DroidsHttpClient.java
    incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/protocol/http/HttpContentEntity.java
    incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/protocol/http/HttpProtocol.java
    incubator/droids/trunk/pom.xml

Modified: incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/api/Worker.java
URL: http://svn.apache.org/viewvc/incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/api/Worker.java?rev=983393&r1=983392&r2=983393&view=diff
==============================================================================
--- incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/api/Worker.java (original)
+++ incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/api/Worker.java Sun
Aug  8 12:00:36 2010
@@ -17,7 +17,7 @@
 package org.apache.droids.api;
 
 import java.io.IOException;
-import java.io.Serializable;
+
 
 import org.apache.droids.exception.DroidsException;
 
@@ -26,12 +26,12 @@ import org.apache.droids.exception.Droid
  * A worker is the unit that is doing the actual work. A {@link Droid} is the
  * "project manger" that delegates the work to worker units. Worker units are
  * implemented as threads to scale they number if more work is to do.
- * 
+ *
  * @version 1.0
- * 
+ *
  */
 public interface Worker<T extends Task> {
-  
+
   void execute( final T task ) throws DroidsException, IOException;
-  
+
 }

Modified: incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/protocol/http/AdvancedHttpContentEntity.java
URL: http://svn.apache.org/viewvc/incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/protocol/http/AdvancedHttpContentEntity.java?rev=983393&r1=983392&r2=983393&view=diff
==============================================================================
--- incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/protocol/http/AdvancedHttpContentEntity.java
(original)
+++ incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/protocol/http/AdvancedHttpContentEntity.java
Sun Aug  8 12:00:36 2010
@@ -33,12 +33,12 @@ public class AdvancedHttpContentEntity e
   private Map<String,String> metadata = new HashMap<String,String>();
   private long contentLength;
   
-  public AdvancedHttpContentEntity(HttpEntity entity) throws IOException {
-    super(entity);
+  public AdvancedHttpContentEntity(HttpEntity entity, long maxlen) throws IOException {
+    super(entity, maxlen);
   }
 
-  public AdvancedHttpContentEntity(HttpEntity entity, Header[] allHeaders) throws IOException
{
-    super(entity);
+  public AdvancedHttpContentEntity(HttpEntity entity, Header[] allHeaders, long maxlen) throws
IOException {
+    super(entity, maxlen);
     for(Header h : allHeaders) {
       metadata.put(h.getName(), h.getValue());
     }

Modified: incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/protocol/http/AdvancedHttpProtocol.java
URL: http://svn.apache.org/viewvc/incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/protocol/http/AdvancedHttpProtocol.java?rev=983393&r1=983392&r2=983393&view=diff
==============================================================================
--- incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/protocol/http/AdvancedHttpProtocol.java
(original)
+++ incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/protocol/http/AdvancedHttpProtocol.java
Sun Aug  8 12:00:36 2010
@@ -56,7 +56,8 @@ public class AdvancedHttpProtocol extend
       // Should _almost_ never happen with HTTP GET requests.
       throw new ClientProtocolException("Empty entity");
     }
-    return new AdvancedHttpContentEntity(entity,response.getAllHeaders());
+    long maxlen = getHttpClient().getParams().getLongParameter(DroidsHttpClient.MAX_BODY_LENGTH,
0);
+    return new AdvancedHttpContentEntity(entity,response.getAllHeaders(),maxlen);
   }
 }
 

Added: incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/protocol/http/ContentTooLongException.java
URL: http://svn.apache.org/viewvc/incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/protocol/http/ContentTooLongException.java?rev=983393&view=auto
==============================================================================
--- incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/protocol/http/ContentTooLongException.java
(added)
+++ incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/protocol/http/ContentTooLongException.java
Sun Aug  8 12:00:36 2010
@@ -0,0 +1,31 @@
+/*
+ * 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.
+ */
+package org.apache.droids.protocol.http;
+
+import java.io.IOException;
+
+public class ContentTooLongException extends IOException
+{
+
+  private static final long serialVersionUID = -3118026295438863279L;
+
+  public ContentTooLongException(String message) 
+  {
+    super();
+  }
+  
+}

Propchange: incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/protocol/http/ContentTooLongException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/protocol/http/ContentTooLongException.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/protocol/http/ContentTooLongException.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/protocol/http/DroidHttpEntity.java
URL: http://svn.apache.org/viewvc/incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/protocol/http/DroidHttpEntity.java?rev=983393&view=auto
==============================================================================
--- incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/protocol/http/DroidHttpEntity.java
(added)
+++ incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/protocol/http/DroidHttpEntity.java
Sun Aug  8 12:00:36 2010
@@ -0,0 +1,115 @@
+/*
+ * 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.
+ */
+package org.apache.droids.protocol.http;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import org.apache.http.HttpEntity;
+import org.apache.http.entity.HttpEntityWrapper;
+import org.apache.http.util.ByteArrayBuffer;
+
+class DroidHttpEntity extends HttpEntityWrapper
+{
+  private final byte[] buffer;
+
+  public DroidHttpEntity(final HttpEntity entity, long maxlen) throws IOException
+  {
+    super(entity);
+    if (!entity.isRepeatable() || entity.getContentLength() < 0)
+    {
+      InputStream instream = entity.getContent();
+      ByteArrayBuffer buf = new ByteArrayBuffer(4096);
+      try
+      {
+        byte[] tmp = new byte[4096];
+        long total = 0;
+        int l;
+        while ((l = instream.read(tmp)) != -1)
+        {
+          buf.append(tmp, 0, l);
+          total += l;
+          if (maxlen > 0 && total >= maxlen) {
+            throw new ContentTooLongException("Content length exceeds " + maxlen + " byte
limit");
+          }
+        }
+        this.buffer = buf.toByteArray();
+      } finally
+      {
+        instream.close();
+      }
+    } else
+    {
+      this.buffer = null;
+    }
+  }
+
+  public long getContentLength()
+  {
+    if (this.buffer != null)
+    {
+      return this.buffer.length;
+    } else
+    {
+      return wrappedEntity.getContentLength();
+    }
+  }
+
+  public InputStream getContent() throws IOException
+  {
+    if (this.buffer != null)
+    {
+      return new ByteArrayInputStream(this.buffer);
+    } else
+    {
+      return wrappedEntity.getContent();
+    }
+  }
+
+  public boolean isChunked()
+  {
+    return (buffer == null) && wrappedEntity.isChunked();
+  }
+
+  public boolean isRepeatable()
+  {
+    return true;
+  }
+
+  public void writeTo(final OutputStream outstream) throws IOException
+  {
+    if (outstream == null)
+    {
+      throw new IllegalArgumentException("Output stream may not be null");
+    }
+    if (this.buffer != null)
+    {
+      outstream.write(this.buffer);
+    } else
+    {
+      wrappedEntity.writeTo(outstream);
+    }
+  }
+
+  public boolean isStreaming()
+  {
+    return (buffer == null) && wrappedEntity.isStreaming();
+  }
+
+}

Propchange: incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/protocol/http/DroidHttpEntity.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/protocol/http/DroidHttpEntity.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/protocol/http/DroidHttpEntity.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/protocol/http/DroidsHttpClient.java
URL: http://svn.apache.org/viewvc/incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/protocol/http/DroidsHttpClient.java?rev=983393&r1=983392&r2=983393&view=diff
==============================================================================
--- incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/protocol/http/DroidsHttpClient.java
(original)
+++ incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/protocol/http/DroidsHttpClient.java
Sun Aug  8 12:00:36 2010
@@ -49,11 +49,10 @@ import org.apache.http.impl.client.Defau
 import org.apache.http.impl.client.DefaultRedirectHandler;
 import org.apache.http.impl.client.DefaultUserTokenHandler;
 import org.apache.http.impl.conn.ProxySelectorRoutePlanner;
-import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
 import org.apache.http.params.BasicHttpParams;
-import org.apache.http.params.HttpConnectionParams;
+import org.apache.http.params.CoreConnectionPNames;
+import org.apache.http.params.CoreProtocolPNames;
 import org.apache.http.params.HttpParams;
-import org.apache.http.params.HttpProtocolParams;
 import org.apache.http.protocol.BasicHttpContext;
 import org.apache.http.protocol.BasicHttpProcessor;
 import org.apache.http.protocol.HTTP;
@@ -74,6 +73,8 @@ import org.apache.http.protocol.RequestU
 public class DroidsHttpClient extends AbstractHttpClient
 {
 
+  public static final String MAX_BODY_LENGTH = "droids.http..max-body-length";
+  
   public DroidsHttpClient()
   {
     super(null, null);
@@ -88,10 +89,16 @@ public class DroidsHttpClient extends Ab
   protected HttpParams createHttpParams()
   {
     HttpParams params = new BasicHttpParams();
-    HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
-    HttpProtocolParams.setContentCharset(params, HTTP.DEFAULT_CONTENT_CHARSET);
-    HttpProtocolParams.setUseExpectContinue(params, true);
-    HttpConnectionParams.setStaleCheckingEnabled(params, false);
+    params.setParameter(CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_1);
+    params.setParameter(CoreProtocolPNames.HTTP_CONTENT_CHARSET, HTTP.DEFAULT_CONTENT_CHARSET);
+    params.setParameter(CoreProtocolPNames.USE_EXPECT_CONTINUE, false);
+    params.setParameter(CoreConnectionPNames.STALE_CONNECTION_CHECK, false);
+    params.setIntParameter(CoreConnectionPNames.MAX_HEADER_COUNT, 256);
+    params.setIntParameter(CoreConnectionPNames.MAX_LINE_LENGTH, 5 * 1024);
+    params.setIntParameter(CoreConnectionPNames.SO_TIMEOUT, 20000);
+    params.setIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, 20000);
+    params.setParameter(CoreConnectionPNames.TCP_NODELAY, false);
+    params.setLongParameter(MAX_BODY_LENGTH, 512 * 1024);
     return params;
   }
 
@@ -118,7 +125,7 @@ public class DroidsHttpClient extends Ab
     SchemeRegistry schemeRegistry = new SchemeRegistry();
     schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
     schemeRegistry.register(new Scheme("https", SSLSocketFactory.getSocketFactory(), 443));
-    return new ThreadSafeClientConnManager(getParams(), schemeRegistry);
+    return new DroidsHttpConnectionManager(getParams(), schemeRegistry);
   }
 
   @Override

Added: incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/protocol/http/DroidsHttpConnection.java
URL: http://svn.apache.org/viewvc/incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/protocol/http/DroidsHttpConnection.java?rev=983393&view=auto
==============================================================================
--- incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/protocol/http/DroidsHttpConnection.java
(added)
+++ incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/protocol/http/DroidsHttpConnection.java
Sun Aug  8 12:00:36 2010
@@ -0,0 +1,47 @@
+/*
+ * 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.
+ */
+package org.apache.droids.protocol.http;
+
+import org.apache.http.HttpResponseFactory;
+import org.apache.http.impl.conn.DefaultClientConnection;
+import org.apache.http.impl.conn.DefaultResponseParser;
+import org.apache.http.io.HttpMessageParser;
+import org.apache.http.io.SessionInputBuffer;
+import org.apache.http.params.HttpParams;
+
+class DroidsHttpConnection extends DefaultClientConnection
+{
+
+  public DroidsHttpConnection()
+  {
+    super();
+  }
+
+  @Override
+  protected HttpMessageParser createResponseParser(
+      SessionInputBuffer buffer,
+      HttpResponseFactory responseFactory, 
+      HttpParams params)
+  {
+    return new DefaultResponseParser(
+        buffer, 
+        new LenientHttpResponseParser(), 
+        responseFactory,
+        params);
+  }
+
+}

Propchange: incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/protocol/http/DroidsHttpConnection.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/protocol/http/DroidsHttpConnection.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/protocol/http/DroidsHttpConnection.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/protocol/http/DroidsHttpConnectionManager.java
URL: http://svn.apache.org/viewvc/incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/protocol/http/DroidsHttpConnectionManager.java?rev=983393&view=auto
==============================================================================
--- incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/protocol/http/DroidsHttpConnectionManager.java
(added)
+++ incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/protocol/http/DroidsHttpConnectionManager.java
Sun Aug  8 12:00:36 2010
@@ -0,0 +1,38 @@
+/*
+ * 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.
+ */
+package org.apache.droids.protocol.http;
+
+import org.apache.http.conn.ClientConnectionOperator;
+import org.apache.http.conn.scheme.SchemeRegistry;
+import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
+import org.apache.http.params.HttpParams;
+
+class DroidsHttpConnectionManager extends ThreadSafeClientConnManager
+{
+
+  public DroidsHttpConnectionManager(HttpParams params, SchemeRegistry schemes)
+  {
+    super(params, schemes);
+  }
+
+  @Override
+  protected ClientConnectionOperator createConnectionOperator(SchemeRegistry schemes)
+  {
+    return new DroidsHttpConnectionOperator(schemes);
+  }
+  
+}

Propchange: incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/protocol/http/DroidsHttpConnectionManager.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/protocol/http/DroidsHttpConnectionManager.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/protocol/http/DroidsHttpConnectionManager.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/protocol/http/DroidsHttpConnectionOperator.java
URL: http://svn.apache.org/viewvc/incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/protocol/http/DroidsHttpConnectionOperator.java?rev=983393&view=auto
==============================================================================
--- incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/protocol/http/DroidsHttpConnectionOperator.java
(added)
+++ incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/protocol/http/DroidsHttpConnectionOperator.java
Sun Aug  8 12:00:36 2010
@@ -0,0 +1,37 @@
+/*
+ * 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.
+ */
+package org.apache.droids.protocol.http;
+
+import org.apache.http.conn.OperatedClientConnection;
+import org.apache.http.conn.scheme.SchemeRegistry;
+import org.apache.http.impl.conn.DefaultClientConnectionOperator;
+
+class DroidsHttpConnectionOperator extends DefaultClientConnectionOperator
+{
+
+  public DroidsHttpConnectionOperator(SchemeRegistry schemes)
+  {
+    super(schemes);
+  }
+
+  @Override
+  public OperatedClientConnection createConnection()
+  {
+    return new DroidsHttpConnection();
+  }
+
+}

Propchange: incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/protocol/http/DroidsHttpConnectionOperator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/protocol/http/DroidsHttpConnectionOperator.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/protocol/http/DroidsHttpConnectionOperator.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/protocol/http/HttpContentEntity.java
URL: http://svn.apache.org/viewvc/incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/protocol/http/HttpContentEntity.java?rev=983393&r1=983392&r2=983393&view=diff
==============================================================================
--- incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/protocol/http/HttpContentEntity.java
(original)
+++ incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/protocol/http/HttpContentEntity.java
Sun Aug  8 12:00:36 2010
@@ -26,7 +26,6 @@ import org.apache.http.Header;
 import org.apache.http.HeaderElement;
 import org.apache.http.HttpEntity;
 import org.apache.http.NameValuePair;
-import org.apache.http.entity.BufferedHttpEntity;
 import org.apache.http.protocol.HTTP;
 
 public class HttpContentEntity implements ManagedContentEntity {
@@ -37,12 +36,12 @@ public class HttpContentEntity implement
   
   private Parse parse = null;
   
-  public HttpContentEntity(HttpEntity entity) throws IOException {
+  public HttpContentEntity(HttpEntity entity, long maxlen) throws IOException {
     super();
     if (entity.isRepeatable()) {
       this.entity = entity;
     } else {
-      this.entity = new BufferedHttpEntity(entity);
+      this.entity = new DroidHttpEntity(entity, maxlen);
     }
     
     String mimeType = null;

Modified: incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/protocol/http/HttpProtocol.java
URL: http://svn.apache.org/viewvc/incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/protocol/http/HttpProtocol.java?rev=983393&r1=983392&r2=983393&view=diff
==============================================================================
--- incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/protocol/http/HttpProtocol.java
(original)
+++ incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/protocol/http/HttpProtocol.java
Sun Aug  8 12:00:36 2010
@@ -72,7 +72,8 @@ public class HttpProtocol extends Loggab
       // Should _almost_ never happen with HTTP GET requests.
       throw new ClientProtocolException("Empty entity");
     }
-    return new HttpContentEntity(entity);
+    long maxlen = httpclient.getParams().getLongParameter(DroidsHttpClient.MAX_BODY_LENGTH,
0);
+    return new HttpContentEntity(entity, maxlen);
   }
 
   public boolean isAllowed(URI uri) {

Added: incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/protocol/http/LenientHttpResponseParser.java
URL: http://svn.apache.org/viewvc/incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/protocol/http/LenientHttpResponseParser.java?rev=983393&view=auto
==============================================================================
--- incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/protocol/http/LenientHttpResponseParser.java
(added)
+++ incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/protocol/http/LenientHttpResponseParser.java
Sun Aug  8 12:00:36 2010
@@ -0,0 +1,41 @@
+/*
+ * 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.
+ */
+package org.apache.droids.protocol.http;
+
+import org.apache.http.Header;
+import org.apache.http.ParseException;
+import org.apache.http.message.BasicHeader;
+import org.apache.http.message.BasicLineParser;
+import org.apache.http.util.CharArrayBuffer;
+
+class LenientHttpResponseParser extends BasicLineParser
+{
+
+  @Override
+  public Header parseHeader(CharArrayBuffer buffer) throws ParseException
+  {
+    try
+    {
+      return super.parseHeader(buffer);
+    } catch (ParseException ex)
+    {
+      // Suppress ParseException exception
+      return new BasicHeader(buffer.toString(), null);
+    }
+  }
+
+}

Propchange: incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/protocol/http/LenientHttpResponseParser.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/protocol/http/LenientHttpResponseParser.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: incubator/droids/trunk/droids-core/src/main/java/org/apache/droids/protocol/http/LenientHttpResponseParser.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: incubator/droids/trunk/pom.xml
URL: http://svn.apache.org/viewvc/incubator/droids/trunk/pom.xml?rev=983393&r1=983392&r2=983393&view=diff
==============================================================================
--- incubator/droids/trunk/pom.xml (original)
+++ incubator/droids/trunk/pom.xml Sun Aug  8 12:00:36 2010
@@ -34,7 +34,7 @@
    Droids - an intelligent robot framework
   </description>
   <url>http://incubator.apache.org/droids/</url>
-  <packaging>pom</packaging>  
+  <packaging>pom</packaging>
 
   <licenses>
     <license>
@@ -53,7 +53,7 @@
     <system>jira</system>
     <url>http://issues.apache.org/jira/browse/DROIDS</url>
   </issueManagement>
-  
+
   <mailingLists>
     <mailingList>
       <name>Droids Development List</name>
@@ -79,7 +79,7 @@
     <maven.compile.deprecation>true</maven.compile.deprecation>
     <commons-logging.version>1.1.1</commons-logging.version>
     <commons-io.version>1.4</commons-io.version>
-    <httpclient.version>4.0</httpclient.version>
+    <httpclient.version>4.0.1</httpclient.version>
     <nekohtml.version>1.9.6.2</nekohtml.version>
     <log4j.version>1.2.14</log4j.version>
     <spring-conf.version>2.0.0</spring-conf.version>
@@ -124,7 +124,7 @@
         <artifactId>cocoon-spring-configurator</artifactId>
         <version>${spring-conf.version}</version>
       </dependency>
-      
+
       <!-- TESTING -->
       <dependency>
         <groupId>junit</groupId>
@@ -154,7 +154,7 @@
         <configuration>
           <downloadSources>true</downloadSources>
         </configuration>
-      </plugin>     
+      </plugin>
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-surefire-plugin</artifactId>
@@ -165,10 +165,10 @@
         <artifactId>surefire-report-maven-plugin</artifactId>
         <inherited>true</inherited>
       </plugin>
-      
+
       <plugin>
          <!-- Add SVN Revision To A JAR Manifest
-            - http://maven.apache.org/plugin-developers/cookbook/add-svn-revision-to-manifest.html

+            - http://maven.apache.org/plugin-developers/cookbook/add-svn-revision-to-manifest.html
            -->
         <groupId>org.codehaus.mojo</groupId>
         <artifactId>buildnumber-maven-plugin</artifactId>
@@ -185,29 +185,29 @@
           <doUpdate>false</doUpdate>
         </configuration>
       </plugin>
-      
+
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-jar-plugin</artifactId>        
+        <artifactId>maven-jar-plugin</artifactId>
         <version>2.2</version>
         <configuration>
           <archive>
             <addMavenDescriptor>false</addMavenDescriptor>
-            <manifestEntries>              
+            <manifestEntries>
               <Specification-Title>Apache ${project.name}</Specification-Title>
               <Specification-Version>${project.version}</Specification-Version>
               <Specification-Vendor>The Apache Software Foundation</Specification-Vendor>
               <Implementation-Title>${project.name}</Implementation-Title>
               <Implementation-Version>${project.version} ${buildNumber} - ${user.name}</Implementation-Version>
               <Implementation-Vendor>The Apache Software Foundation</Implementation-Vendor>
-              <SCM-Revision>${buildNumber}</SCM-Revision>   
+              <SCM-Revision>${buildNumber}</SCM-Revision>
               <SCM-url>${scm.url}</SCM-url>
             </manifestEntries>
           </archive>
         </configuration>
       </plugin>
-      
-    </plugins>  
+
+    </plugins>
   </build>
 
   <reporting>
@@ -251,7 +251,7 @@
       </releases>
     </repository>
   </repositories>
-  
+
   <!-- DROIDS-70 / INFRA-2368 -->
 <!--  <distributionManagement>
       <snapshotRepository>
@@ -261,7 +261,7 @@
       </snapshotRepository>
   </distributionManagement>-->
 
-  
+
   <modules>
     <module>droids-norobots</module>
     <module>droids-core</module>



Mime
View raw message