cn.xishan.oftenporter.bridge.http.RequestData Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of Porter-Bridge-Http Show documentation
Show all versions of Porter-Bridge-Http Show documentation
转接远程的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