aboutsummaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorame <[email protected]>2024-09-30 02:17:37 -0500
committerame <[email protected]>2024-09-30 02:17:37 -0500
commitc18a2ac9469ddc7488834a81e49150ebb5506ed4 (patch)
tree2a9fafd40359419d36504b55e6041a9fdda23bc6 /docs
parent2a7f5c95a5406b6de215dbc24a733e29d609d20f (diff)
parente29d3ea86551380ace8e2c86c9f1f63e901941e1 (diff)
what
Diffstat (limited to 'docs')
-rw-r--r--docs/net.md45
1 files changed, 42 insertions, 3 deletions
diff --git a/docs/net.md b/docs/net.md
index e548cb1..0807c72 100644
--- a/docs/net.md
+++ b/docs/net.md
@@ -12,12 +12,41 @@ right now everything within a server:GET function is partially global, it can re
it can not read/copy local variables or modify globals
**
+allows a third optional argument that offers some other options in a table format
+
+|name|default value|extra info|
+|--|--|--|
+|mime.types.file**|/etc/mime.types|formated similarly to [this](https://wiki.debian.org/MIME/etc/mime.types)|
+|max.connections**|64|maximum number of connections that can be opened at the same time, will respond with error(503)|
+|max.header.size**|1<<20 (1048576)|max header size before refusing connection with error(431)|
+|max.uri.size**|idk yet|maximum uri size before refusing request with error(414)|
+|max.request.timeout**|idk yet|maximum time server will wait for request to be parsed|
+
+
+the server will send these codes for these reasons
+|code|cause|
+|--|--|
+|503**|too many current requests, more than max.connections|
+|500**|anytime a server route crashes|
+|431**|header is larger than max header size, more than max.header.size|
+|414**|request uri is longer than max.uri.size|
+|408**|request took too longer than max.request.timeout|
+|404**|request has no defined route|
+
+(more to come?**)
+
```lua
llib.net.listen(function(server)
...
end, 80)
```
+```lua
+llib.net.listen(function(server)
+ ...
+end, 80, {["mime.types.file"] = "/etc/mime.types"})
+```
+
### server:lock server:unlock
continues on the current thread, but pauses all other threads at that point
@@ -48,13 +77,13 @@ the actual name of the function will change based on what request method you wan
```lua
server:all("*", function(res, req)
if(req['Version'] ~= "HTTP/1.1") then
- res:close()
+ res:stop()
end
end)
...
server:GET("/", function(res, req)
- --version will always be 1.1, as per the middleware
+ --version will always be 1.1, because the request passes through the function sequentially
...
end)
...
@@ -69,7 +98,7 @@ end)
'takes a string
sends the string to the client, constructs a header on first call (whether or not res.header._sent is null)
-(the constructed header can not be changed later on in the request), and sends the string without closing the client
+(the constructed header can not be changed later on in the request*), and sends the string without closing the client
```lua
...
@@ -78,6 +107,8 @@ res:write("<h1>good bye world</h1>")
...
```
+*well it can but it wont do anything
+
#### res:send
'takes a string
@@ -94,6 +125,12 @@ res:send("<h1>hello world</h1>")
closes connection, sets res.client_fd to -1, any calls that use this value will fail
+this will still run any selected functions!
+
+#### res:stop
+
+prevents all further selected functions from running
+
#### res.header
table containing all head information, anything added to it will be used, certain keys will affect other values or have other side effects on res:send, listed below
@@ -119,6 +156,8 @@ res.header["test"] = "wowa"
'takes one string, which is a path that will be served, must be a file
+res.header["Content-Type"] is set automatically depending on the file extention, using /etc/mime.types, or whatever option was supplied to listen (see listen options)
+
```lua
...
res:sendfile("./html/index.html")