aboutsummaryrefslogtreecommitdiffstats
path: root/examples/static_server.rb
diff options
context:
space:
mode:
authorKazuki Yamaguchi <k@rhe.jp>2015-07-17 11:41:03 +0900
committerKazuki Yamaguchi <k@rhe.jp>2015-07-17 11:41:03 +0900
commitaf9e3ae93adaf6903e0d2b7bbec806f505294a6a (patch)
treeeee82ff05ade5ee5164716c33b43d3b1273cd584 /examples/static_server.rb
parent2733cc466d7b8ae701d8686de3aeb1e92966e020 (diff)
downloadplum-af9e3ae93adaf6903e0d2b7bbec806f505294a6a.tar.gz
stream: add api for automatic splitting frame
Diffstat (limited to 'examples/static_server.rb')
-rw-r--r--examples/static_server.rb20
1 files changed, 8 insertions, 12 deletions
diff --git a/examples/static_server.rb b/examples/static_server.rb
index e0a308b..1c32d99 100644
--- a/examples/static_server.rb
+++ b/examples/static_server.rb
@@ -86,40 +86,36 @@ loop do
<input type=submit>
</form>
EOF
- stream.send_headers({
+ stream.respond({
":status": "200",
"server": "plum",
"content-type": "text/html",
"content-length": body.size
- })
- stream.send_body(body, [:end_stream])
+ }, body)
when ["GET", "/abc.html"]
body = "ABC! <a href=/>Back to top page</a>"
- stream.send_headers({
+ stream.respond({
":status": "200",
"server": "plum",
"content-type": "text/html",
"content-length": body.size
- })
- stream.send_body(body, [:end_stream])
+ }, body)
when ["POST", "/post.page"]
body = "Posted value is: #{CGI.unescape(data).gsub("<", "&lt;").gsub(">", "&gt;")}<br> <a href=/>Back to top page</a>"
- stream.send_headers({
+ stream.respond({
":status": "200",
"server": "plum",
"content-type": "text/html",
"content-length": body.size
- })
- stream.send_body(body, [:end_stream])
+ }, body)
else
body = "Page not found! <a href=/>Back to top page</a>"
- stream.send_headers({
+ stream.respond({
":status": "404",
"server": "plum",
"content-type": "text/html",
"content-length": body.size
- })
- stream.send_body(body, [:end_stream])
+ }, body)
end
end
end