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

cn.xishan.oftenporter.bridge.http.RequestData Maven / Gradle / Ivy

Go to download

转接远程的http接口,服务器响应正确的数据格式必须是JResponse定义的格式。 客户端websocket使用"org.java-websocket:Java-WebSocket:1.5.2",项目地址https://github.com/TooTallNate/Java-WebSocket; 对Java-WebSocket做了适当修改。

The newest version!
package cn.xishan.oftenporter.bridge.http;

import cn.xishan.oftenporter.servlet.ContentType;

import java.io.File;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by https://github.com/CLovinr on 2017/8/10.
 */
public class RequestData
{
    private ContentType contentType = ContentType.APP_FORM_URLENCODED;
    private Object bodyContent;
    private String encoding;
    private Map headers;
    private Map params;

    public RequestData()
    {
    }

    public RequestData(Map params)
    {
        this.params = params;
    }

    public Map getParams()
    {
        return params;
    }

    public Map getHeaders()
    {
        return headers;
    }

    public void setParams(Map params)
    {
        this.params = params;
    }

    public void setHeaders(Map headers)
    {
        this.headers = headers;
    }

    public RequestData putParam(String name, Object value)
    {
        if (params == null)
        {
            params = new HashMap<>();
        }
        params.put(name, value);
        return this;
    }

    public RequestData putHeader(String name, String value)
    {
        if (headers == null)
        {
            headers = new HashMap<>();
        }
        headers.put(name, value);
        return this;
    }

    public ContentType getContentType()
    {
        return contentType;
    }

    public void setContentType(ContentType contentType)
    {
        this.contentType = contentType;
    }

    public Object getBodyContent()
    {
        return bodyContent;
    }

    public void setBodyContent(InputStream content)
    {
        this.bodyContent = content;
    }

    public void setBodyContent(File content)
    {
        this.bodyContent = content;
    }

    public void setBodyContent(byte[] content)
    {
        this.bodyContent = content;
    }

    public void setBodyContent(String bodyContent)
    {
        this.bodyContent = bodyContent;
    }

    public String getEncoding()
    {
        return encoding;
    }

    public void setEncoding(String encoding)
    {
        this.encoding = encoding;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy