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

com.manywho.sdk.services.servers.lambda.LambdaRequestContext Maven / Gradle / Ivy

There is a newer version: 2.0.1
Show newest version
package com.manywho.sdk.services.servers.lambda;

import org.apache.commons.fileupload.RequestContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.io.InputStream;
import java.util.Map;

public class LambdaRequestContext implements RequestContext {
    private final static Logger LOGGER = LoggerFactory.getLogger(LambdaRequestContext.class);

    private final InputStream body;
    private final Map headers;

    public LambdaRequestContext(InputStream body, Map headers) {
        this.body = body;
        this.headers = headers;
    }

    @Override
    public String getCharacterEncoding() {
        return null;
    }

    @Override
    public String getContentType() {
        return headers.get("Content-Type");
    }

    @Override
    public int getContentLength() {
        try {
            return body.available();
        } catch (IOException e) {
            LOGGER.error("Unable to find the content length of the request", e);

            throw new RuntimeException("Unable to find the content length of the request", e);
        }
    }

    @Override
    public InputStream getInputStream() {
        return body;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy