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:
Paul Kulchenko 2022-04-20 00:24:25 -07:00 committed by GitHub
parent 5a132f9652
commit c3fb624647
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 12 deletions

View file

@ -1186,7 +1186,7 @@ RE MODULE
re.NEWLINE
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 "."
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
re.NOTBOL), and (3) a "$" shall match the zero-length string
immediately before a NEWLINE (regardless of re.NOTEOL).
@ -1297,8 +1297,8 @@ UNIX MODULE
unix.commandv(prog:str) → path:str[, errno:int]
Performs `$PATH` lookup of executable. We automatically suffix
`.com` and `.exe` automatically for all platforms when path
searching. By default, the current directory is not on the path.
`.com` and `.exe` for all platforms when path searching.
By default, the current directory is not on the path.
If `prog` is an absolute path, then it's returned as-is. If
`prog` contains slashes then it's not path searched either and
will be returned if it exists.
@ -1393,13 +1393,13 @@ UNIX MODULE
unix.setgid(gid:int) → 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
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`,
`LOG_CRIT`, `LOG_ERR`, `LOG_WARNING`, `LOG_NOTICE`, `LOG_INFO`,
`LOG_DEBUG`.

View file

@ -1498,8 +1498,8 @@ static const luaL_Reg kLuaUnix[] = {
{"fdatasync", LuaUnixFdatasync}, // flush open file w/o metadata
{"truncate", LuaUnixTruncate}, // shrink or extend file medium
{"ftruncate", LuaUnixTruncate}, // shrink or extend file medium
{"umask", LuaUnixUmask}, // change root directory
{"chroot", LuaUnixChroot}, // get parent process id
{"umask", LuaUnixUmask}, // set default file mask
{"chroot", LuaUnixChroot}, // change root directory
{"setrlimit", LuaUnixSetrlimit}, // prevent cpu memory bombs
{"getrlimit", LuaUnixGetrlimit}, // query resource limits
{"getppid", LuaUnixGetppid}, // get parent process id

View file

@ -2060,8 +2060,7 @@ static char *AppendHeader(char *p, const char *k, const char *v) {
static char *AppendContentType(char *p, const char *ct) {
p = stpcpy(p, "Content-Type: ");
p = stpcpy(p, ct);
if (startswith(ct, "text/")) {
istext = true;
if ((istext = startswith(ct, "text/"))) {
if (!strchr(ct + 5, ';')) {
p = stpcpy(p, "; charset=utf-8");
}
@ -2443,6 +2442,7 @@ static int LuaCallWithYield(lua_State *L) {
YL = co;
generator = YieldGenerator;
if (!isyielding) isyielding = 1;
istext = false; // reset istext flag to avoid zipping yielded chunk
status = LUA_OK;
}
return status;
@ -6286,7 +6286,7 @@ static char *SetStatus(unsigned code, const char *reason) {
if (code == 308) code = 301;
}
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 ");
hdrbuf.p[7] += msg.version & 1;
hdrbuf.p[9] += code / 100;
@ -6476,7 +6476,7 @@ static void InitRequest(void) {
luaheaderp = 0;
isyielding = 0;
contentlength = 0;
hascontenttype = false;
hascontenttype = istext = false;
referrerpolicy = 0;
InitHttpMessage(&msg, kHttpRequest);
}