Skip to content

Commit

Permalink
Merge pull request nutzam#525 from ywjno/master
Browse files Browse the repository at this point in the history
给 request 添加个 inputStream 属性
  • Loading branch information
pangwu86 committed Sep 25, 2013
2 parents 7e57f92 + d785e2c commit a430837
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/org/nutz/http/Request.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ private Request() {}
private Map<String, Object> params;
private byte[] data;
private URL cacheUrl;
private InputStream inputStream;

public URL getUrl() {
if (cacheUrl != null) {
Expand Down Expand Up @@ -95,11 +96,19 @@ public String getURLEncodedParams() {
}

public InputStream getInputStream() {
// TODO 需要根据请求来进行编码,这里首先先固定用 UTF-8 好了
if (null == data) {
return new ByteArrayInputStream(Strings.getBytesUTF8(getURLEncodedParams()));
if (inputStream != null) {
return inputStream;
} else {
// TODO 需要根据请求来进行编码,这里首先先固定用 UTF-8 好了
if (null == data) {
return new ByteArrayInputStream(Strings.getBytesUTF8(getURLEncodedParams()));
}
return new ByteArrayInputStream(data);
}
return new ByteArrayInputStream(data);
}

public void setInputStream(InputStream inputStream) {
this.inputStream = inputStream;
}

public byte[] getData() {
Expand Down

0 comments on commit a430837

Please sign in to comment.