diff options
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/common.md | 22 | ||||
| -rw-r--r-- | docs/net/listen.md | 4 |
2 files changed, 26 insertions, 0 deletions
diff --git a/docs/common.md b/docs/common.md new file mode 100644 index 0000000..c0d5be7 --- /dev/null +++ b/docs/common.md @@ -0,0 +1,22 @@ +## errors + +errors will typically be created and propogated using luaI_error (in c) but will always retain a common style (unless mentioned otherwise) + +it will return 3 values, in order + +* nil (just always a nil value first, useful to do a quick check for errors on functions with a return value) +* string (an error message) +* integer (an error code) + +similarily, when luaI_assert is called, the string will be the expression and the integer will be -1 + +## stream + +this is a generic function used in many places. + +stream:read(?bytes) +stream:file(filename, ?bytes, ?mode) + +bytes is an optional value allowing you to select how many bytes at maximum to read. this value can be ignored or adjusted by the function, and if so, it will be noted in the docs (default is nil, and will read as much as possible) + +mode is the mode the file will be opened with (defaults to "w") diff --git a/docs/net/listen.md b/docs/net/listen.md index f64c6f2..cc464b3 100644 --- a/docs/net/listen.md +++ b/docs/net/listen.md @@ -146,6 +146,8 @@ res.header["test"] = "wowa" res:sendfile(filepath, options?)
+this can return an error if the file is not found or if the user does not have read permissions
+
res.header["Content-Type"] is set automatically (unless already set) depending on the file extention, using /etc/mime.types, or whatever option was supplied to listen (see listen options)
options table
@@ -184,6 +186,8 @@ these can, of course be used with wildcards however you want req:roll(bytes?)
+> this will be changed to be a stream internally, see common.md
+
when bytes is null it will read as much as possible (may not be the full request)
will update req according to how the bytes needed to be parsed, returns the number of bytes read (not necessarily parsed), 0 if there
|
