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

org.solovyev.android.http.DownloadFileHttpTransaction Maven / Gradle / Ivy

There is a newer version: 1.1.18
Show newest version
package org.solovyev.android.http;

import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.jetbrains.annotations.NotNull;
import org.solovyev.common.Converter;

import java.io.IOException;
import java.io.InputStream;
import java.util.Collections;
import java.util.List;

/**
 * User: serso
 * Date: 5/29/12
 * Time: 9:51 PM
 */
public class DownloadFileHttpTransaction extends AbstractHttpTransaction {

    @NotNull
    private final Converter fileConverter;

    public DownloadFileHttpTransaction(@NotNull String uri, @NotNull HttpMethod httpMethod, @NotNull Converter fileConverter) {
        super(uri, httpMethod);
        this.fileConverter = fileConverter;
    }

    @NotNull
    @Override
    public List getRequestParameters() {
        return Collections.emptyList();
    }

    @Override
    public R getResponse(@NotNull HttpResponse response) {
        try {
            return fileConverter.convert(response.getEntity().getContent());
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy