Title: [857] trunk/rails-integration/src: 16108 - HttpOutput flush doesnt send headers - Patch by Matt Burke
Revision
857
Author
tantalon
Date
2007-12-17 17:33:06 -0500 (Mon, 17 Dec 2007)

Log Message

16108 - HttpOutput flush doesnt send headers - Patch by Matt Burke

Modified Paths


Diff

Modified: trunk/rails-integration/src/main/java/org/jruby/webapp/HttpOutput.java (856 => 857)


--- trunk/rails-integration/src/main/java/org/jruby/webapp/HttpOutput.java	2007-12-16 06:12:52 UTC (rev 856)
+++ trunk/rails-integration/src/main/java/org/jruby/webapp/HttpOutput.java	2007-12-17 22:33:06 UTC (rev 857)
@@ -145,8 +145,10 @@
 	public void flush() throws IOException {
 		if (output != null) {
 			output.flush();
-			response.flushBuffer();
+		} else {
+			writeHeaders();
 		}
+		response.flushBuffer();
 	}
 
 	public void close() throws IOException {

Modified: trunk/rails-integration/src/test/java/org/jruby/webapp/HttpOutputTest.java (856 => 857)


--- trunk/rails-integration/src/test/java/org/jruby/webapp/HttpOutputTest.java	2007-12-16 06:12:52 UTC (rev 856)
+++ trunk/rails-integration/src/test/java/org/jruby/webapp/HttpOutputTest.java	2007-12-17 22:33:06 UTC (rev 857)
@@ -67,5 +67,33 @@
 		assertEquals("", out.getContent());
 	}
 
+	public void test304ForOnlyFlush() throws IOException {
+		String input =
+			"Content-Type: text/html; charset=utf-8\r\n" +
+			"Set-Cookie: _rebates_session=413aa062523b7b9fe0d491beff1ccc0d; path=/\r\n" +
+			"ETag: \"f37ab55cc5ab52d83496448cfed2aca6\"\r\n" +
+			"X-Runtime: 0.37500\r\n" +
+			"Content-Length: 0\r\n" +
+			"Cache-Control: private, max-age=0, must-revalidate\r\n" +
+			"Status: 304 Not Modified\r\n" +
+			"\r\n";
+		// setup expectations
+		response.setStatus(304);
+		response.setContentType("text/html; charset=utf-8");
+		response.addHeader("Set-Cookie", "_rebates_session=413aa062523b7b9fe0d491beff1ccc0d; path=/");
+		response.addHeader("ETag", "\"f37ab55cc5ab52d83496448cfed2aca6\"");
+		response.addHeader("X-Runtime", "0.37500");
+		response.addHeader("Content-Length", "0");
+		response.addHeader("Cache-Control", "private, max-age=0, must-revalidate");
+		response.flushBuffer();
+		control.replay();
+		// execute the action
+		HttpOutput httpOutput = new HttpOutput(response);
+		httpOutput.write(input.getBytes());
+		httpOutput.flush();
+		// verify the results
+		control.verify();
+	}
 
+
 }
_______________________________________________
Jruby-extras-devel mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/jruby-extras-devel

Reply via email to