package org.jerrymouse.cc.site.web.utils;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;

import javax.ws.rs.core.HttpHeaders;

import org.apache.commons.fileupload.RequestContext;

public class CCRequestContext implements RequestContext {
	byte[] data;
	HttpHeaders httpHeaders;

	public CCRequestContext(byte[] data, HttpHeaders httpHeaders) {
		this.data = data;
		this.httpHeaders = httpHeaders;
	}

	public String getCharacterEncoding() {
		return "utf-8";
	}

	public int getContentLength() {
		return data.length;
	}

	public String getContentType() {
		return httpHeaders.getMediaType().toString();
	}

	public InputStream getInputStream() throws IOException {
		return new ByteArrayInputStream(data);
	}

}
