add default constructor for HttpRequestBody #609

master
yihua.huang 2017-06-24 11:31:17 +08:00
parent eb376fca74
commit f405e642c0
1 changed files with 18 additions and 3 deletions

View File

@ -29,11 +29,14 @@ public class HttpRequestBody implements Serializable {
public static final String MULTIPART = "multipart/form-data";
}
private final byte[] body;
private byte[] body;
private final String contentType;
private String contentType;
private final String encoding;
private String encoding;
public HttpRequestBody() {
}
public HttpRequestBody(byte[] body, String contentType, String encoding) {
this.body = body;
@ -49,6 +52,18 @@ public class HttpRequestBody implements Serializable {
return encoding;
}
public void setBody(byte[] body) {
this.body = body;
}
public void setContentType(String contentType) {
this.contentType = contentType;
}
public void setEncoding(String encoding) {
this.encoding = encoding;
}
public static HttpRequestBody json(String json, String encoding) throws UnsupportedEncodingException {
return new HttpRequestBody(json.getBytes(encoding), ContentType.JSON, encoding);
}