All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.koushikdutta.async.http.StreamPart Maven / Gradle / Ivy

Go to download

Asynchronous socket, http(s) (client+server) and websocket library for android. Based on nio, not threads.

There is a newer version: 3.1.0
Show newest version
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;
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy