hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1639702 - in /httpcomponents/httpcore/branches/4.4.x/httpcore/src/main/java/org/apache/http: entity/BasicHttpEntity.java impl/BHttpConnectionBase.java impl/io/EmptyInputStream.java
Date Fri, 14 Nov 2014 17:09:51 GMT
Author: olegk
Date: Fri Nov 14 17:09:51 2014
New Revision: 1639702

URL: http://svn.apache.org/r1639702
Log:
Set EmptyInputStream in entity instead of ContentLengthInputStream(inbuffer, 0)
Contributed by Dmitry Potapov <dpotapov at yandex-team.ru>

Added:
    httpcomponents/httpcore/branches/4.4.x/httpcore/src/main/java/org/apache/http/impl/io/EmptyInputStream.java
  (with props)
Modified:
    httpcomponents/httpcore/branches/4.4.x/httpcore/src/main/java/org/apache/http/entity/BasicHttpEntity.java
    httpcomponents/httpcore/branches/4.4.x/httpcore/src/main/java/org/apache/http/impl/BHttpConnectionBase.java

Modified: httpcomponents/httpcore/branches/4.4.x/httpcore/src/main/java/org/apache/http/entity/BasicHttpEntity.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/branches/4.4.x/httpcore/src/main/java/org/apache/http/entity/BasicHttpEntity.java?rev=1639702&r1=1639701&r2=1639702&view=diff
==============================================================================
--- httpcomponents/httpcore/branches/4.4.x/httpcore/src/main/java/org/apache/http/entity/BasicHttpEntity.java
(original)
+++ httpcomponents/httpcore/branches/4.4.x/httpcore/src/main/java/org/apache/http/entity/BasicHttpEntity.java
Fri Nov 14 17:09:51 2014
@@ -32,6 +32,7 @@ import java.io.InputStream;
 import java.io.OutputStream;
 
 import org.apache.http.annotation.NotThreadSafe;
+import org.apache.http.impl.io.EmptyInputStream;
 import org.apache.http.util.Args;
 import org.apache.http.util.Asserts;
 
@@ -124,7 +125,7 @@ public class BasicHttpEntity extends Abs
 
     @Override
     public boolean isStreaming() {
-        return this.content != null;
+        return this.content != null && this.content != EmptyInputStream.INSTANCE;
     }
 
 }

Modified: httpcomponents/httpcore/branches/4.4.x/httpcore/src/main/java/org/apache/http/impl/BHttpConnectionBase.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/branches/4.4.x/httpcore/src/main/java/org/apache/http/impl/BHttpConnectionBase.java?rev=1639702&r1=1639701&r2=1639702&view=diff
==============================================================================
--- httpcomponents/httpcore/branches/4.4.x/httpcore/src/main/java/org/apache/http/impl/BHttpConnectionBase.java
(original)
+++ httpcomponents/httpcore/branches/4.4.x/httpcore/src/main/java/org/apache/http/impl/BHttpConnectionBase.java
Fri Nov 14 17:09:51 2014
@@ -56,6 +56,7 @@ import org.apache.http.impl.io.ChunkedIn
 import org.apache.http.impl.io.ChunkedOutputStream;
 import org.apache.http.impl.io.ContentLengthInputStream;
 import org.apache.http.impl.io.ContentLengthOutputStream;
+import org.apache.http.impl.io.EmptyInputStream;
 import org.apache.http.impl.io.HttpTransportMetricsImpl;
 import org.apache.http.impl.io.IdentityInputStream;
 import org.apache.http.impl.io.IdentityOutputStream;
@@ -207,6 +208,8 @@ public class BHttpConnectionBase impleme
             return new ChunkedInputStream(inbuffer, this.messageConstraints);
         } else if (len == ContentLengthStrategy.IDENTITY) {
             return new IdentityInputStream(inbuffer);
+        } else if (len == 0L) {
+            return EmptyInputStream.INSTANCE;
         } else {
             return new ContentLengthInputStream(inbuffer, len);
         }

Added: httpcomponents/httpcore/branches/4.4.x/httpcore/src/main/java/org/apache/http/impl/io/EmptyInputStream.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/branches/4.4.x/httpcore/src/main/java/org/apache/http/impl/io/EmptyInputStream.java?rev=1639702&view=auto
==============================================================================
--- httpcomponents/httpcore/branches/4.4.x/httpcore/src/main/java/org/apache/http/impl/io/EmptyInputStream.java
(added)
+++ httpcomponents/httpcore/branches/4.4.x/httpcore/src/main/java/org/apache/http/impl/io/EmptyInputStream.java
Fri Nov 14 17:09:51 2014
@@ -0,0 +1,84 @@
+/*
+ * ====================================================================
+ * 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.impl.io;
+
+import java.io.InputStream;
+
+/**
+ * @since 4.4
+ */
+public final class EmptyInputStream extends InputStream {
+
+    public static final EmptyInputStream INSTANCE = new EmptyInputStream();
+
+    private EmptyInputStream() {
+    }
+
+    @Override
+    public int available() {
+        return 0;
+    }
+
+    @Override
+    public void close() {
+    }
+
+    @Override
+    public void mark(final int readLimit) {
+    }
+
+    @Override
+    public boolean markSupported() {
+        return true;
+    }
+
+    @Override
+    public int read() {
+        return -1;
+    }
+
+    @Override
+    public int read(final byte[] buf) {
+        return -1;
+    }
+
+    @Override
+    public int read(final byte[] buf, final int off, final int len) {
+        return -1;
+    }
+
+    @Override
+    public void reset() {
+    }
+
+    @Override
+    public long skip(final long n) {
+        return 0L;
+    }
+}
+

Propchange: httpcomponents/httpcore/branches/4.4.x/httpcore/src/main/java/org/apache/http/impl/io/EmptyInputStream.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: httpcomponents/httpcore/branches/4.4.x/httpcore/src/main/java/org/apache/http/impl/io/EmptyInputStream.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: httpcomponents/httpcore/branches/4.4.x/httpcore/src/main/java/org/apache/http/impl/io/EmptyInputStream.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message