diff --git a/src/org/nutz/http/Request.java b/src/org/nutz/http/Request.java index 01e5bba77..351c90cd9 100644 --- a/src/org/nutz/http/Request.java +++ b/src/org/nutz/http/Request.java @@ -59,6 +59,7 @@ private Request() {} private Map params; private byte[] data; private URL cacheUrl; + private InputStream inputStream; public URL getUrl() { if (cacheUrl != null) { @@ -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() {