diff --git a/libc/nexgen32e/x86feature.h b/libc/nexgen32e/x86feature.h index 913d9f0d2..2656b587e 100644 --- a/libc/nexgen32e/x86feature.h +++ b/libc/nexgen32e/x86feature.h @@ -140,6 +140,7 @@ #define X86_XSAVE 1H, ECX, 26, _X86_CC_XSAVE, _ /* sandybridge c. 2012 */ #define X86_XTPR 1H, ECX, 14, 0, _ #define X86_ZERO_FCS_FDS 7H, EBX, 13, 0, _ +#define X86_JIT 80000001H, ECX, 31, 0, _ /* IsGenuineBlink() */ /* clang-format on */ /* AMD specific features */ diff --git a/tool/net/redbean.c b/tool/net/redbean.c index a1bca3a13..93182c64f 100644 --- a/tool/net/redbean.c +++ b/tool/net/redbean.c @@ -636,6 +636,10 @@ static void DropOutput(void) { cpm.outbuf = 0; } +static bool ShouldAvoidGzip(void) { + return IsGenuineCosmo() || (IsGenuineBlink() && !X86_HAVE(JIT)); +} + static char *MergePaths(const char *p, size_t n, const char *q, size_t m, size_t *z) { char *r; @@ -2438,7 +2442,10 @@ static char *CommitOutput(char *p) { if (!IsTiny() && !IsSslCompressed()) { p = stpcpy(p, "Vary: Accept-Encoding\r\n"); } - if (!IsTiny() && !IsSslCompressed() && ClientAcceptsGzip()) { + if (!IsTiny() && // + !IsSslCompressed() && // + ClientAcceptsGzip() && // + !ShouldAvoidGzip()) { cpm.gzipped = outbuflen; crc = crc32_z(0, cpm.outbuf, outbuflen); WRITE32LE(gzip_footer + 0, crc); @@ -6148,7 +6155,7 @@ static char *ServeAsset(struct Asset *a, const char *path, size_t pathlen) { return ServeError(500, "Internal Server Error"); } } else if (!IsTiny() && cpm.msg.method != kHttpHead && !IsSslCompressed() && - ClientAcceptsGzip() && + ClientAcceptsGzip() && !ShouldAvoidGzip() && !(a->file && IsNoCompressExt(a->file->path.s, a->file->path.n)) && ((cpm.contentlength >= 100 && _startswithi(ct, "text/")) ||