com.koushikdutta.async.http.StreamPart Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of androidasync Show documentation
Show all versions of androidasync Show documentation
Asynchronous socket, http(s) (client+server) and websocket library for android. Based on nio, not threads.
package com.koushikdutta.async.http;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import org.apache.http.NameValuePair;
import com.koushikdutta.async.DataSink;
import com.koushikdutta.async.callback.CompletedCallback;
public abstract class StreamPart extends Part {
public StreamPart(String name, int length, List contentDisposition) {
super(name, length, contentDisposition);
}
@Override
public void write(DataSink sink, CompletedCallback callback) {
try {
InputStream is = getInputStream();
com.koushikdutta.async.Util.pump(is, sink, callback);
}
catch (Exception e) {
callback.onCompleted(e);
}
}
protected abstract InputStream getInputStream() throws IOException;
}