Permalink
Browse files

test stub for sendfile

  • Loading branch information...
1 parent 4567d32 commit 9cbc012455fc8bb553ccc95ce58100e9e2287291 @peter-leonov committed May 18, 2010
Showing with 52 additions and 1 deletion.
  1. +1 −0 js/Handler.js
  2. +49 −0 js/tests/sendfile.js
  3. +1 −1 nginx.conf
  4. +1 −0 sendfile-1.txt
View
@@ -77,6 +77,7 @@ require('tests/standart-classes.js')
require('tests/subrequests.js')
require('tests/subrequest-headers-out.js')
require('tests/subrequest-headers-in.js')
+require('tests/sendfile.js')
// require('tests/cascade-tests.js')
// require('tests/timer-parallel.js')
// require('tests/timer-order.js')
View
@@ -0,0 +1,49 @@
+;(function(){
+
+NginxTests.sendfile = function (r)
+{
+ r.sendHttpHeader('text/plain; charset=utf-8')
+
+ Tests.test('sendfile', function (t)
+ {
+ function callback (sr, body, rc)
+ {
+ t.ok(body, 'response body')
+
+ t.done()
+ }
+
+ r.subrequest('/loopback/run/sendfile-handler', callback)
+
+ t.wait(3000)
+ })
+ Tests.oncomplete = function ()
+ {
+ r.sendSpecial(Nginx.HTTP_LAST)
+ }
+ Tests.run(r)
+
+ return Nginx.OK
+}
+
+NginxTests.sendfileHandler = function (r)
+{
+ r.sendHttpHeader('text/plain; charset=utf-8')
+ r.flush()
+
+ // all these four commants add just a specific buffer to the output chain
+ // r.sendfile('/etc/passwd')
+ r.print('before:')
+ r.flush()
+
+ r.sendfile(Nginx.prefix + 'sendfile-1.txt')
+
+ r.print(':after')
+ r.flush()
+
+ r.sendSpecial(Nginx.HTTP_LAST)
+
+ return Nginx.OK
+}
+
+})();
View
@@ -28,7 +28,7 @@ http
access_log off;
- sendfile on;
+ sendfile on;
keepalive_timeout 65;
server
View
@@ -0,0 +1 @@
+ha-ha, sendme!

0 comments on commit 9cbc012

Please sign in to comment.