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

com.ithit.webdav.integration.android.AndroidDavRequest Maven / Gradle / Ivy

The newest version!
package com.ithit.webdav.integration.android;

import com.ithit.webdav.server.DavRequest;
import fi.iki.elonen.NanoHTTPD;

import java.io.IOException;
import java.io.InputStream;
import java.util.Enumeration;
import java.util.Vector;

/**
 * NanoHttpd specific implementation of DavRequest.
 */
public class AndroidDavRequest extends DavRequest {

    private final NanoHTTPD.IHTTPSession iHttpSession;
    private final AndroidServerConfig androidServerConfig;
    private final AndroidInputStream androidInputStream;

    public AndroidDavRequest(NanoHTTPD.IHTTPSession iHttpSession, AndroidServerConfig androidServerConfig) {
        this.iHttpSession = iHttpSession;
        this.androidServerConfig = androidServerConfig;
        androidInputStream = new AndroidInputStream(iHttpSession);
    }

    public String getHeader(String name) {
        return iHttpSession.getHeaders().get(name.toLowerCase());
    }

    public String getMethod() {
        return iHttpSession.getMethod().toString();
    }

    public String getRequestURI() {
        return iHttpSession.getUri();
    }

    public String getQueryString() {
        return null;
    }

    public String getContextPath() {
        return "";
    }

    public String getServerPath() {
        return "/";
    }

    public int getServerPort() {
        return androidServerConfig.getPort();
    }

    public String getScheme() {
        return androidServerConfig.getScheme();
    }

    public String getServerName() {
        return androidServerConfig.getServerName();
    }

    public String getCharacterEncoding() {
        return null;
    }

    public InputStream getInputStream() throws IOException {
        return androidInputStream;
    }

    public long getContentLength() {
        String s = iHttpSession.getHeaders().get("content-length");
        return Long.parseLong(s);
    }

    public String getContentType() {
        return iHttpSession.getHeaders().get("content-type");
    }

    public Enumeration getHeaderNames() {
        return new Vector(iHttpSession.getHeaders().keySet()).elements();
    }

    public Object getOriginalRequest() {
        return iHttpSession;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy