|
Revision 247, 492 bytes
(checked in by nahi, 2 years ago)
|
- added download.cgi for chunked encoding test.
|
- Property svn:executable set to
*
|
| Line | |
|---|
| 1 |
#!/usr/local/bin/ruby |
|---|
| 2 |
|
|---|
| 3 |
print "Content-Type: application/octet-stream\r\n" |
|---|
| 4 |
print "Transfer-Encoding: chunked\r\n" |
|---|
| 5 |
print "\r\n" |
|---|
| 6 |
|
|---|
| 7 |
def dump_chunk_size(size) |
|---|
| 8 |
sprintf("%x", size) + "\r\n" |
|---|
| 9 |
end |
|---|
| 10 |
|
|---|
| 11 |
def dump_chunk(str) |
|---|
| 12 |
dump_chunk_size(str.size) + str + "\r\n" |
|---|
| 13 |
end |
|---|
| 14 |
|
|---|
| 15 |
buf_size = 1024 * 16 |
|---|
| 16 |
STDOUT.sync = true |
|---|
| 17 |
File.open(File.expand_path('10M.bin', File.dirname(__FILE__))) do |file| |
|---|
| 18 |
buf = '' |
|---|
| 19 |
while !file.read(buf_size, buf).nil? |
|---|
| 20 |
print dump_chunk(buf) |
|---|
| 21 |
end |
|---|
| 22 |
print dump_chunk_size(0) + "\r\n" |
|---|
| 23 |
end |
|---|