Skip to content

Commit 448ae80

Browse files
committed
Update sendfile example.
1 parent 686049d commit 448ae80

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

examples/sendfile.ooc

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@ use web, fastcgi
22

33
import web/Application
44
import fastcgi/Server
5-
import io/[Reader, FileReader]
5+
import io/[FileReader, File]
66

77

8-
//TODO: update this to use the new body() writer
98
SendFile: class extends Application {
10-
processRequest: func -> Reader {
9+
processRequest: func {
10+
file := File new("../README")
11+
1112
response setHeader("Content-type", "text/plain; charset=utf-8")
12-
return FileReader new("../README")
13+
response setHeader("Content-length", file size() toString())
14+
response body() write(FileReader new(file))
1315
}
1416
}
1517

0 commit comments

Comments
 (0)