Redbean doc update (#221)

- Update redbean documentation for consistency and fix typo (#97)
- Update redbean constants for consistency
- Add Fetch documentation to redbean (#97)
This commit is contained in:
Paul Kulchenko 2021-08-03 17:57:15 -07:00 committed by GitHub
parent f7b4804251
commit 344d2dc356
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 9 deletions

View file

@ -533,6 +533,14 @@ FUNCTIONS
EscapeUser(str) → str
Escapes URL username. See kescapeauthority.c.
Fetch(url:str[,body:str|{method=value:str,body=value:str}])
→ status:int,{header:str=value:str,...},body:str
Sends an HTTP/HTTPS request to the specified URL. If only the URL is
provided, then a GET request is sent. If both URL and body parameters
are specified, then a POST request is sent. If any other method needs
to be specified (for example, PUT or DELETE), then passing a table as
the second value allows setting method and body values.
FormatHttpDateTime(seconds:int) → rfc1123:str
Converts UNIX timestamp to an RFC1123 string that looks like this:
Mon, 29 Mar 2021 15:37:13 GMT. See formathttpdatetime.c.
@ -591,7 +599,7 @@ FUNCTIONS
message, then this function will fold those multiple entries into
a single string.
GetHeaders() → {name:str = value:str, ...}
GetHeaders() → {name:str=value:str,...}
Returns HTTP headers as dictionary mapping header key strings to
their UTF-8 decoded values. The ordering of headers from the
request message is not preserved. Whether or not the same key can
@ -625,7 +633,7 @@ FUNCTIONS
Anything else that the RFC classifies as a "token" string is
accepted too, which might contain characters like &".
GetParams() → {{name:str[, value:str]}, ...}
GetParams() → {{name:str[,value:str]},...}
Returns name=value parameters from Request-URL and
application/x-www-form-urlencoded message body in the order they
were received. This may contain duplicates. The inner array will
@ -673,7 +681,7 @@ FUNCTIONS
minor (mm), and patch (pp) versions encoded. The version value 1.4
would be represented as 0x010400.
GetZipPaths() → array[str]
GetZipPaths() → {path:str,...}
Returns paths of all assets in the zip central directory, prefixed
by a slash.
@ -866,7 +874,7 @@ FUNCTIONS
Sleep(seconds:number)
Sleeps the specified number of seconds (can be fractional). The
smallest interval is a millisecond.
smallest interval is a microsecond.
Route([host:str,[path:str]])
Instructs redbean to follow the normal HTTP serving path. This

View file

@ -1172,8 +1172,8 @@ static void AppendResourceReport(struct rusage *ru, const char *nl) {
if (ru->ru_maxrss) {
Append("ballooned to %,ldkb in size%s", ru->ru_maxrss, nl);
}
if ((utime = ru->ru_utime.tv_sec * 1000000 + ru->ru_utime.tv_usec) |
(stime = ru->ru_stime.tv_sec * 1000000 + ru->ru_stime.tv_usec)) {
if ((utime = ru->ru_utime.tv_sec * 1e6 + ru->ru_utime.tv_usec) |
(stime = ru->ru_stime.tv_sec * 1e6 + ru->ru_stime.tv_usec)) {
ticks = ceill((long double)(utime + stime) / (1000000.L / CLK_TCK));
Append("needed %,ldµs cpu (%d%% kernel)%s", utime + stime,
(int)((long double)stime / (utime + stime) * 100), nl);
@ -1223,8 +1223,8 @@ static void AppendResourceReport(struct rusage *ru, const char *nl) {
static void AddTimeval(struct timeval *x, const struct timeval *y) {
x->tv_sec += y->tv_sec;
x->tv_usec += y->tv_usec;
if (x->tv_usec >= 1000000) {
x->tv_usec -= 1000000;
if (x->tv_usec >= 1e6) {
x->tv_usec -= 1e6;
x->tv_sec += 1;
}
}
@ -4886,7 +4886,7 @@ static int LuaLog(lua_State *L) {
}
static int LuaSleep(lua_State *L) {
usleep(1000000 * luaL_checknumber(L, 1));
usleep(1e6 * luaL_checknumber(L, 1));
return 0;
}