diff options
author | Kazuki Yamaguchi <k@rhe.jp> | 2015-07-17 11:41:03 +0900 |
---|---|---|
committer | Kazuki Yamaguchi <k@rhe.jp> | 2015-07-17 11:41:03 +0900 |
commit | af9e3ae93adaf6903e0d2b7bbec806f505294a6a (patch) | |
tree | eee82ff05ade5ee5164716c33b43d3b1273cd584 /examples/static_server.rb | |
parent | 2733cc466d7b8ae701d8686de3aeb1e92966e020 (diff) | |
download | plum-af9e3ae93adaf6903e0d2b7bbec806f505294a6a.tar.gz |
stream: add api for automatic splitting frame
Diffstat (limited to 'examples/static_server.rb')
-rw-r--r-- | examples/static_server.rb | 20 |
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("<", "<").gsub(">", ">")}<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 |