package de.sebse.fuplanner.tools.network;

import com.android.volley.toolbox.HttpHeaderParser;

import java.io.UnsupportedEncodingException;
import java.util.Map;

import de.sebse.fuplanner.tools.logging.Logger;

/**
 * Created by sebastian on 24.10.17.
 */
public class Result {
    private final byte[] body;
    private final Map<String, String> headers;

    public Result(byte[] body, Map<String, String> headers) {
        this.body = body;
        this.headers = headers;
    }

    public String getParsed() {
        try {
            return new String(this.body, HttpHeaderParser.parseCharset(headers));
        } catch (UnsupportedEncodingException e) {
            return new String(this.body);
        }
    }

    public byte[] getBytes() {
        return body;
    }

    public Map<String, String> getHeaders() {
        return headers;
    }
}
