Add some missing functions to the documentation

functions:
- GetHttpReason
- IsHiddenPath
- IsAcceptablePath
- IsReasonablePath
- ProgramTimeout

also fixed another typo
This commit is contained in:
w13b3 2022-07-16 12:42:18 +02:00
parent 1a89a1b523
commit c5a493ede2

View file

@ -1159,6 +1159,10 @@ FUNCTIONS
HTTP/0.9, 10 for HTTP/1.0, or 11 for HTTP/1.1. HTTP/0.9, 10 for HTTP/1.0, or 11 for HTTP/1.1.
Also available as GetVersion (deprecated). Also available as GetVersion (deprecated).
GetHttpReason(code:int) → str
Returns a string describing the HTTP reason phrase.
See gethttpreason.c
GetRandomBytes([length:int]) → str GetRandomBytes([length:int]) → str
Returns string with the specified number of random bytes (1..256). Returns string with the specified number of random bytes (1..256).
If no length is specified, then a string of length 16 is returned. If no length is specified, then a string of length 16 is returned.
@ -1181,6 +1185,9 @@ FUNCTIONS
Programs redbean / listing page to not display any paths beginning Programs redbean / listing page to not display any paths beginning
with prefix. This function should only be called from /.init.lua. with prefix. This function should only be called from /.init.lua.
IsHiddenPath(path:str) → bool
Returns true if the prefix of the given path is set with HidePath.
IsPublicIp(uint32) → bool IsPublicIp(uint32) → bool
Returns true if IP address is not a private network (10.0.0.0/8, Returns true if IP address is not a private network (10.0.0.0/8,
172.16.0.0/12, 192.168.0.0/16) and is not localhost (127.0.0.0/8). 172.16.0.0/12, 192.168.0.0/16) and is not localhost (127.0.0.0/8).
@ -1256,6 +1263,14 @@ FUNCTIONS
like data:opaque, better in fact than most things which claim to like data:opaque, better in fact than most things which claim to
be URI parsers. be URI parsers.
IsAcceptablePath(str) → bool
Returns true if path doesn't contain ".", ".." or "//" segments
See isacceptablepath.c
IsReasonablePath(str) → bool
Returns true if path doesn't contain "." or ".." segments.
See isreasonablepath.c
EncodeUrl(URL) → str EncodeUrl(URL) → str
This function is the inverse of ParseUrl. The output will always This function is the inverse of ParseUrl. The output will always
be correctly formatted. The exception is if illegal characters are be correctly formatted. The exception is if illegal characters are
@ -1314,6 +1329,11 @@ FUNCTIONS
as Content-Range and Date, which are abstracted by the transport as Content-Range and Date, which are abstracted by the transport
layer. layer.
ProgramTimeout(milliseconds:int|seconds:int)
Default timeout is 60000ms. Minimal value of timeout is 10(ms).
Negative values (<0) sets the keepalive in seconds.
This should only be called from /.init.lua.
ProgramPort(uint16) ProgramPort(uint16)
Hard-codes the port number on which to listen, which can be any Hard-codes the port number on which to listen, which can be any
number in the range 1..65535, or alternatively 0 to ask the number in the range 1..65535, or alternatively 0 to ask the
@ -1325,7 +1345,7 @@ FUNCTIONS
default is very conservatively set to 65536 so this is default is very conservatively set to 65536 so this is
something many people will want to increase. This limit is something many people will want to increase. This limit is
enforced at the transport layer, before any Lua code is enforced at the transport layer, before any Lua code is
called, because right now redbean stores and forewards called, because right now redbean stores and forwards
messages. (Use the UNIX API for raw socket streaming.) Setting messages. (Use the UNIX API for raw socket streaming.) Setting
this to a very high value can be useful if you're less this to a very high value can be useful if you're less
concerned about rogue clients and would rather have your Lua concerned about rogue clients and would rather have your Lua