com.ithit.webdav.integration.android.AndroidDavResponse Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of android-integration Show documentation
Show all versions of android-integration Show documentation
ITHit WebDAV integration for android based on NanoHttpd
The newest version!
package com.ithit.webdav.integration.android;
import com.ithit.webdav.server.DavResponse;
import java.io.*;
import java.util.HashMap;
import java.util.Map;
/**
* NanoHttpd specific implementation of DavResponse.
*/
public class AndroidDavResponse extends DavResponse {
private final Map headers = new HashMap();
private ByteArrayOutputStream inMemoryOutputStream;
private String contentType;
private String encoding;
private long length = -1;
private Status status = new Status(200, "Ok");
public AndroidDavResponse() {
inMemoryOutputStream = new ByteArrayOutputStream();
}
public void addHeader(String name, String value) {
headers.put(name, value);
}
public void setStatus(int code, String description) {
this.status = new Status(code, description);
}
public void setContentLength(long length) {
this.length = length;
}
public void setContentType(String type) {
contentType = type;
}
public void setCharacterEncoding(String encoding) {
this.encoding = encoding;
}
public OutputStream getOutputStream() throws IOException {
return inMemoryOutputStream;
}
public void setHeader(String name, String value) {
headers.put(name, value);
}
public Object getOriginalResponse() {
return this;
}
public String getContentType() {
return contentType + "; charset=utf-8";
}
public String getEncoding() {
return encoding;
}
public long getLength() {
return length;
}
public Status getStatus() {
return status;
}
public InputStream getInputStream() {
return new ByteArrayInputStream(inMemoryOutputStream.toByteArray());
}
public Map getHeaders() {
return headers;
}
}