Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

* added download.cgi for chunked encoding test.

  • Loading branch information...
commit 14104a4cb76ef614bc74b57c7b4263e14caeb215 1 parent b4f5e66
nahi authored
Showing with 23 additions and 0 deletions.
  1. +23 −0 bench/download.cgi
View
23 bench/download.cgi
@@ -0,0 +1,23 @@
+#!/usr/local/bin/ruby
+
+print "Content-Type: application/octet-stream\r\n"
+print "Transfer-Encoding: chunked\r\n"
+print "\r\n"
+
+def dump_chunk_size(size)
+ sprintf("%x", size) + "\r\n"
+end
+
+def dump_chunk(str)
+ dump_chunk_size(str.size) + str + "\r\n"
+end
+
+buf_size = 1024 * 16
+STDOUT.sync = true
+File.open(File.expand_path('10M.bin', File.dirname(__FILE__))) do |file|
+ buf = ''
+ while !file.read(buf_size, buf).nil?
+ print dump_chunk(buf)
+ end
+ print dump_chunk_size(0) + "\r\n"
+end

0 comments on commit 14104a4

Please sign in to comment.
Something went wrong with that request. Please try again.