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

@ -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);
}