Skip to content

Commit

Permalink
max-age should be an integer + docs
Browse files Browse the repository at this point in the history
  • Loading branch information
boazsegev committed Nov 28, 2024
1 parent 1ed413d commit 565949e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
21 changes: 21 additions & 0 deletions examples/config.nru
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,25 @@
# Iodine can run both Rack and NeoRack applications.
#
# In this case the `on_http` implementation will be prioritized over the `call` implementation.
#
# Benchmark with keep-alive:
#
# ab -c 200 -t 4 -n 1000000 -k http://127.0.0.1:3000/
# wrk -c200 -d4 -t2 http://localhost:3000/
#
# Connect to chat server with WebSockets:
#
# ws = new WebSocket("ws://" + document.location.host + document.location.pathname);
# ws.onmessage = function(e) {console.log("Got message!"); console.log(e.data);};
# ws.onclose = function(e) {console.log("closed")};
# ws.onopen = function(e) {ws.send("hi");};
#
# Listen to chat messages with Server Sent Events (EventSource / SSE):
#
# const listener = new EventSource(document.location.href);
# listener.onmessage = (e) => { console.log(e); }
# listener.onevent = (e) => { console.log(e); }
#
module App
def self.call(e)
txt = []
Expand All @@ -23,6 +42,7 @@ module App
e.write "method: #{e.method}\r\n"
e.write "version: #{e.version}\r\n"
e.write "from: #{e.from} (real: #{e.peer_addr})\r\n"
# e.write "thread: #{Thread.current.to_s}\r\n"
e.headers.each {|k,v| e.write "#{k}: #{v}\r\n" }
# echo request body to the response
while(l = e.gets)
Expand All @@ -35,6 +55,7 @@ module App
# this should optimally result in `content-length` being set by the server
out = "path: #{e.path}\r\nquery: #{e.query}\r\nmethod: #{e.method}\r\nversion: #{e.version}\r\n"
out += "from: #{e.from} (#{e.peer_addr})\r\n"
# out += "thread: #{Thread.current.to_s}\r\n"
e.headers.each {|k,v| out += "#{k}: #{v}\r\n" }
# echo request body to the response
while(l = e.gets)
Expand Down
4 changes: 2 additions & 2 deletions ext/iodine/iodine_cli.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ static VALUE iodine_cli_parse(VALUE self, VALUE required) {
FIO_CLI_INT("--keep-alive -k (" FIO_MACRO2STR(
FIO_HTTP_DEFAULT_TIMEOUT) ") HTTP keep-alive timeout in seconds "
"(0..255)"),
FIO_CLI_BOOL("--max-age -maxage (3600) default Max-Age header value for "
"static files."),
FIO_CLI_INT("--max-age -maxage (3600) default Max-Age header value for "
"static files."),
FIO_CLI_BOOL("--log -v log HTTP messages."),

FIO_CLI_PRINT_HEADER("WebSocket / SSE"),
Expand Down

0 comments on commit 565949e

Please sign in to comment.