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 2009/07/06 20:21:15 UTC
svn commit: r791558 - in /httpcomponents/httpcore/trunk: ./
httpcore-nio/src/main/java/org/apache/http/nio/entity/
httpcore-nio/src/main/java/org/apache/http/nio/util/
Author: olegk
Date: Mon Jul 6 18:21:14 2009
New Revision: 791558
URL: http://svn.apache.org/viewvc?rev=791558&view=rev
Log:
HTTPCORE-199: ContentInputStream implements InputStream#available()
Modified:
httpcomponents/httpcore/trunk/RELEASE_NOTES.txt
httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/entity/ContentInputStream.java
httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/util/SharedInputBuffer.java
httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/util/SharedOutputBuffer.java
Modified: httpcomponents/httpcore/trunk/RELEASE_NOTES.txt
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/RELEASE_NOTES.txt?rev=791558&r1=791557&r2=791558&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/RELEASE_NOTES.txt (original)
+++ httpcomponents/httpcore/trunk/RELEASE_NOTES.txt Mon Jul 6 18:21:14 2009
@@ -1,6 +1,9 @@
Changes since 4.0.1
-------------------
+* [HTTPCORE-199] ContentInputStream implements InputStream#available().
+ Contributed by Oleg Kalnichevski <olegk at apache.org>
+
* [HTTPCORE-195] Truncated chunk-coded streams can now be tolerated by catching and discarding
TruncatedChunkException.
Contributed by Oleg Kalnichevski <olegk at apache.org>
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/entity/ContentInputStream.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/entity/ContentInputStream.java?rev=791558&r1=791557&r2=791558&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/entity/ContentInputStream.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/entity/ContentInputStream.java Mon Jul 6 18:21:14 2009
@@ -34,6 +34,7 @@
import java.io.IOException;
import java.io.InputStream;
+import org.apache.http.nio.util.BufferInfo;
import org.apache.http.nio.util.ContentInputBuffer;
/**
@@ -54,6 +55,15 @@
}
@Override
+ public int available() throws IOException {
+ if (this.buffer instanceof BufferInfo) {
+ return ((BufferInfo) this.buffer).length();
+ } else {
+ return super.available();
+ }
+ }
+
+ @Override
public int read(final byte[] b, int off, int len) throws IOException {
return this.buffer.read(b, off, len);
}
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/util/SharedInputBuffer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/util/SharedInputBuffer.java?rev=791558&r1=791557&r2=791558&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/util/SharedInputBuffer.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/util/SharedInputBuffer.java Mon Jul 6 18:21:14 2009
@@ -104,6 +104,27 @@
}
}
+ @Override
+ public int available() {
+ synchronized (this.mutex) {
+ return super.available();
+ }
+ }
+
+ @Override
+ public int capacity() {
+ synchronized (this.mutex) {
+ return super.capacity();
+ }
+ }
+
+ @Override
+ public int length() {
+ synchronized (this.mutex) {
+ return super.length();
+ }
+ }
+
protected void waitForData() throws IOException {
synchronized (this.mutex) {
try {
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/util/SharedOutputBuffer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/util/SharedOutputBuffer.java?rev=791558&r1=791557&r2=791558&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/util/SharedOutputBuffer.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/util/SharedOutputBuffer.java Mon Jul 6 18:21:14 2009
@@ -73,6 +73,27 @@
}
}
+ @Override
+ public int available() {
+ synchronized (this.mutex) {
+ return super.available();
+ }
+ }
+
+ @Override
+ public int capacity() {
+ synchronized (this.mutex) {
+ return super.capacity();
+ }
+ }
+
+ @Override
+ public int length() {
+ synchronized (this.mutex) {
+ return super.length();
+ }
+ }
+
public int produceContent(final ContentEncoder encoder) throws IOException {
if (this.shutdown) {
return -1;