You are viewing a plain text version of this content. The canonical link for it is here.
Posted to awf-commits@incubator.apache.org by jm...@apache.org on 2011/08/06 10:15:13 UTC
svn commit: r1154478 - in
/incubator/deft/sandbox/src/main/java/org/apache/deft/web/http:
HttpResponse.java HttpResponseImpl.java
Author: jmeehan
Date: Sat Aug 6 10:15:12 2011
New Revision: 1154478
URL: http://svn.apache.org/viewvc?rev=1154478&view=rev
Log:
DEFT-169 - Add extra method for write (byte array).
Modified:
incubator/deft/sandbox/src/main/java/org/apache/deft/web/http/HttpResponse.java
incubator/deft/sandbox/src/main/java/org/apache/deft/web/http/HttpResponseImpl.java
Modified: incubator/deft/sandbox/src/main/java/org/apache/deft/web/http/HttpResponse.java
URL: http://svn.apache.org/viewvc/incubator/deft/sandbox/src/main/java/org/apache/deft/web/http/HttpResponse.java?rev=1154478&r1=1154477&r2=1154478&view=diff
==============================================================================
--- incubator/deft/sandbox/src/main/java/org/apache/deft/web/http/HttpResponse.java (original)
+++ incubator/deft/sandbox/src/main/java/org/apache/deft/web/http/HttpResponse.java Sat Aug 6 10:15:12 2011
@@ -161,12 +161,13 @@ public interface HttpResponse {
HttpResponse write(String data);
/**
- * Explicit flush.
+ * The given data data will be sent as the HTTP response upon next flush or
+ * when the response is finished.
*
- * @return the number of bytes that were actually written as the result of
- * this flush.
+ * @param data the data to write.
+ * @return <code>this</code>, for chaining.
*/
- long flush();
+ HttpResponse write(byte[] data);
/**
* Experimental support. Before use, read
@@ -175,6 +176,14 @@ public interface HttpResponse {
long write(File file);
/**
+ * Explicit flush.
+ *
+ * @return the number of bytes that were actually written as the result of
+ * this flush.
+ */
+ long flush();
+
+ /**
* Should only be invoked by third party asynchronous request handlers (or
* by the Deft framework for synchronous request handlers). If no previous
* (explicit) flush is invoked, the "Content-Length" and (where configured)
Modified: incubator/deft/sandbox/src/main/java/org/apache/deft/web/http/HttpResponseImpl.java
URL: http://svn.apache.org/viewvc/incubator/deft/sandbox/src/main/java/org/apache/deft/web/http/HttpResponseImpl.java?rev=1154478&r1=1154477&r2=1154478&view=diff
==============================================================================
--- incubator/deft/sandbox/src/main/java/org/apache/deft/web/http/HttpResponseImpl.java (original)
+++ incubator/deft/sandbox/src/main/java/org/apache/deft/web/http/HttpResponseImpl.java Sat Aug 6 10:15:12 2011
@@ -161,9 +161,13 @@ public class HttpResponseImpl implements
}
@Override
- public HttpResponseImpl write(String data) {
- byte[] bytes = data.getBytes(Charsets.UTF_8);
- responseData.put(bytes);
+ public HttpResponse write(String data) {
+ return write(data.getBytes(Charsets.UTF_8));
+ }
+
+ @Override
+ public HttpResponse write(byte[] data) {
+ responseData.put(data);
return this;
}
@@ -248,7 +252,7 @@ public class HttpResponseImpl implements
}
private void setEtagAndContentLength() {
-
+
if (createETag && responseData.position() > 0) {
setHeader("Etag", HttpUtil.getEtag(responseData.array()));
}