mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-03-03 07:29:23 +00:00
Redbean fix text detect (#388)
This resets istext between requests, which may cause response to be zipped when not needed (on non-text content).
This commit is contained in:
parent
5a132f9652
commit
c3fb624647
3 changed files with 12 additions and 12 deletions
|
@ -1186,7 +1186,7 @@ RE MODULE
|
||||||
re.NEWLINE
|
re.NEWLINE
|
||||||
Use this flag to change the handling of NEWLINE (\x0a) characters.
|
Use this flag to change the handling of NEWLINE (\x0a) characters.
|
||||||
When this flag is set, (1) a NEWLINE shall not be matched by a "."
|
When this flag is set, (1) a NEWLINE shall not be matched by a "."
|
||||||
or any form of a non-matching list, () a "^" shall match the
|
or any form of a non-matching list, (2) a "^" shall match the
|
||||||
zero-length string immediately after a NEWLINE (regardless of
|
zero-length string immediately after a NEWLINE (regardless of
|
||||||
re.NOTBOL), and (3) a "$" shall match the zero-length string
|
re.NOTBOL), and (3) a "$" shall match the zero-length string
|
||||||
immediately before a NEWLINE (regardless of re.NOTEOL).
|
immediately before a NEWLINE (regardless of re.NOTEOL).
|
||||||
|
@ -1297,8 +1297,8 @@ UNIX MODULE
|
||||||
unix.commandv(prog:str) → path:str[, errno:int]
|
unix.commandv(prog:str) → path:str[, errno:int]
|
||||||
|
|
||||||
Performs `$PATH` lookup of executable. We automatically suffix
|
Performs `$PATH` lookup of executable. We automatically suffix
|
||||||
`.com` and `.exe` automatically for all platforms when path
|
`.com` and `.exe` for all platforms when path searching.
|
||||||
searching. By default, the current directory is not on the path.
|
By default, the current directory is not on the path.
|
||||||
If `prog` is an absolute path, then it's returned as-is. If
|
If `prog` is an absolute path, then it's returned as-is. If
|
||||||
`prog` contains slashes then it's not path searched either and
|
`prog` contains slashes then it's not path searched either and
|
||||||
will be returned if it exists.
|
will be returned if it exists.
|
||||||
|
@ -1393,13 +1393,13 @@ UNIX MODULE
|
||||||
unix.setgid(gid:int) → rc:int[, errno:int]
|
unix.setgid(gid:int) → rc:int[, errno:int]
|
||||||
unix.umask(mask) → rc:int[, errno:int]
|
unix.umask(mask) → rc:int[, errno:int]
|
||||||
|
|
||||||
unix.syslog(priority:str, msg:str)
|
unix.syslog(priority:int, msg:str)
|
||||||
|
|
||||||
Generates a log message which will be distributed by syslogd.
|
Generates a log message, which will be distributed by syslogd.
|
||||||
|
|
||||||
`priority` is a bitmask containing the facility value and the
|
`priority` is a bitmask containing the facility value and the
|
||||||
level value. If no facility value is ORed into priority, then
|
level value. If no facility value is ORed into priority, then
|
||||||
the default value set by openlog() is used. it set to NULL, the
|
the default value set by openlog() is used. If set to NULL, the
|
||||||
program name is used. Level is one of `LOG_EMERG`, `LOG_ALERT`,
|
program name is used. Level is one of `LOG_EMERG`, `LOG_ALERT`,
|
||||||
`LOG_CRIT`, `LOG_ERR`, `LOG_WARNING`, `LOG_NOTICE`, `LOG_INFO`,
|
`LOG_CRIT`, `LOG_ERR`, `LOG_WARNING`, `LOG_NOTICE`, `LOG_INFO`,
|
||||||
`LOG_DEBUG`.
|
`LOG_DEBUG`.
|
||||||
|
|
|
@ -1498,8 +1498,8 @@ static const luaL_Reg kLuaUnix[] = {
|
||||||
{"fdatasync", LuaUnixFdatasync}, // flush open file w/o metadata
|
{"fdatasync", LuaUnixFdatasync}, // flush open file w/o metadata
|
||||||
{"truncate", LuaUnixTruncate}, // shrink or extend file medium
|
{"truncate", LuaUnixTruncate}, // shrink or extend file medium
|
||||||
{"ftruncate", LuaUnixTruncate}, // shrink or extend file medium
|
{"ftruncate", LuaUnixTruncate}, // shrink or extend file medium
|
||||||
{"umask", LuaUnixUmask}, // change root directory
|
{"umask", LuaUnixUmask}, // set default file mask
|
||||||
{"chroot", LuaUnixChroot}, // get parent process id
|
{"chroot", LuaUnixChroot}, // change root directory
|
||||||
{"setrlimit", LuaUnixSetrlimit}, // prevent cpu memory bombs
|
{"setrlimit", LuaUnixSetrlimit}, // prevent cpu memory bombs
|
||||||
{"getrlimit", LuaUnixGetrlimit}, // query resource limits
|
{"getrlimit", LuaUnixGetrlimit}, // query resource limits
|
||||||
{"getppid", LuaUnixGetppid}, // get parent process id
|
{"getppid", LuaUnixGetppid}, // get parent process id
|
||||||
|
|
|
@ -2060,8 +2060,7 @@ static char *AppendHeader(char *p, const char *k, const char *v) {
|
||||||
static char *AppendContentType(char *p, const char *ct) {
|
static char *AppendContentType(char *p, const char *ct) {
|
||||||
p = stpcpy(p, "Content-Type: ");
|
p = stpcpy(p, "Content-Type: ");
|
||||||
p = stpcpy(p, ct);
|
p = stpcpy(p, ct);
|
||||||
if (startswith(ct, "text/")) {
|
if ((istext = startswith(ct, "text/"))) {
|
||||||
istext = true;
|
|
||||||
if (!strchr(ct + 5, ';')) {
|
if (!strchr(ct + 5, ';')) {
|
||||||
p = stpcpy(p, "; charset=utf-8");
|
p = stpcpy(p, "; charset=utf-8");
|
||||||
}
|
}
|
||||||
|
@ -2443,6 +2442,7 @@ static int LuaCallWithYield(lua_State *L) {
|
||||||
YL = co;
|
YL = co;
|
||||||
generator = YieldGenerator;
|
generator = YieldGenerator;
|
||||||
if (!isyielding) isyielding = 1;
|
if (!isyielding) isyielding = 1;
|
||||||
|
istext = false; // reset istext flag to avoid zipping yielded chunk
|
||||||
status = LUA_OK;
|
status = LUA_OK;
|
||||||
}
|
}
|
||||||
return status;
|
return status;
|
||||||
|
@ -6286,7 +6286,7 @@ static char *SetStatus(unsigned code, const char *reason) {
|
||||||
if (code == 308) code = 301;
|
if (code == 308) code = 301;
|
||||||
}
|
}
|
||||||
statuscode = code;
|
statuscode = code;
|
||||||
hascontenttype = false; // reset, as the headers are reset
|
hascontenttype = istext = false; // reset, as the headers are reset
|
||||||
stpcpy(hdrbuf.p, "HTTP/1.0 000 ");
|
stpcpy(hdrbuf.p, "HTTP/1.0 000 ");
|
||||||
hdrbuf.p[7] += msg.version & 1;
|
hdrbuf.p[7] += msg.version & 1;
|
||||||
hdrbuf.p[9] += code / 100;
|
hdrbuf.p[9] += code / 100;
|
||||||
|
@ -6476,7 +6476,7 @@ static void InitRequest(void) {
|
||||||
luaheaderp = 0;
|
luaheaderp = 0;
|
||||||
isyielding = 0;
|
isyielding = 0;
|
||||||
contentlength = 0;
|
contentlength = 0;
|
||||||
hascontenttype = false;
|
hascontenttype = istext = false;
|
||||||
referrerpolicy = 0;
|
referrerpolicy = 0;
|
||||||
InitHttpMessage(&msg, kHttpRequest);
|
InitHttpMessage(&msg, kHttpRequest);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue