"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "fluent-hc/src/main/java/org/apache/http/client/fluent/InternalInputStreamEntity.java" between
httpcomponents-client-4.5.6-src.tar.gz and httpcomponents-client-4.5.7-src.tar.gz

About: HttpComponents is an Apache project responsible for creating and maintaining a toolset of low level Java components focused on HTTP and associated protocols. Java sources.

InternalInputStreamEntity.java  (httpcomponents-client-4.5.6-src):InternalInputStreamEntity.java  (httpcomponents-client-4.5.7-src)
skipping to change at line 43 skipping to change at line 43
import org.apache.http.entity.AbstractHttpEntity; import org.apache.http.entity.AbstractHttpEntity;
import org.apache.http.entity.ContentType; import org.apache.http.entity.ContentType;
import org.apache.http.util.Args; import org.apache.http.util.Args;
class InternalInputStreamEntity extends AbstractHttpEntity { class InternalInputStreamEntity extends AbstractHttpEntity {
private final InputStream content; private final InputStream content;
private final long length; private final long length;
public InternalInputStreamEntity(final InputStream instream, final long leng th, final ContentType contentType) { public InternalInputStreamEntity(final InputStream inputStream, final long l ength, final ContentType contentType) {
super(); super();
this.content = Args.notNull(instream, "Source input stream"); this.content = Args.notNull(inputStream, "Source input stream");
this.length = length; this.length = length;
if (contentType != null) { if (contentType != null) {
setContentType(contentType.toString()); setContentType(contentType.toString());
} }
} }
@Override @Override
public boolean isRepeatable() { public boolean isRepeatable() {
return false; return false;
} }
skipping to change at line 68 skipping to change at line 68
public long getContentLength() { public long getContentLength() {
return this.length; return this.length;
} }
@Override @Override
public InputStream getContent() throws IOException { public InputStream getContent() throws IOException {
return this.content; return this.content;
} }
@Override @Override
public void writeTo(final OutputStream outstream) throws IOException { public void writeTo(final OutputStream outStream) throws IOException {
Args.notNull(outstream, "Output stream"); Args.notNull(outStream, "Output stream");
final InputStream instream = this.content; final InputStream inStream = this.content;
try { try {
final byte[] buffer = new byte[4096]; final byte[] buffer = new byte[4096];
int l; int readLen;
if (this.length < 0) { if (this.length < 0) {
// consume until EOF // consume until EOF
while ((l = instream.read(buffer)) != -1) { while ((readLen = inStream.read(buffer)) != -1) {
outstream.write(buffer, 0, l); outStream.write(buffer, 0, readLen);
} }
} else { } else {
// consume no more than length // consume no more than length
long remaining = this.length; long remaining = this.length;
while (remaining > 0) { while (remaining > 0) {
l = instream.read(buffer, 0, (int)Math.min(4096, remaining)) readLen = inStream.read(buffer, 0, (int)Math.min(4096, remai
; ning));
if (l == -1) { if (readLen == -1) {
break; break;
} }
outstream.write(buffer, 0, l); outStream.write(buffer, 0, readLen);
remaining -= l; remaining -= readLen;
} }
} }
} finally { } finally {
instream.close(); inStream.close();
} }
} }
@Override @Override
public boolean isStreaming() { public boolean isStreaming() {
return true; return true;
} }
} }
 End of changes. 8 change blocks. 
14 lines changed or deleted 14 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)