diff options
author | Tatsuya Kinoshita <tats@debian.org> | 2021-02-11 10:35:39 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-11 10:35:39 +0000 |
commit | 8df4e0355ac259731293baf218396b97e6745898 (patch) | |
tree | ce0a173b9024f4250108811e9e17fa7a4731c8dd | |
parent | Update ChangeLog (diff) | |
parent | Update config.h.dist (diff) | |
download | w3m-8df4e0355ac259731293baf218396b97e6745898.tar.gz w3m-8df4e0355ac259731293baf218396b97e6745898.zip |
Merge pull request #164 from bptato/brotli
Support brotli content encoding
-rw-r--r-- | config.h.dist | 2 | ||||
-rw-r--r-- | config.h.in | 2 | ||||
-rw-r--r-- | file.c | 21 | ||||
-rw-r--r-- | html.h | 1 |
4 files changed, 20 insertions, 6 deletions
diff --git a/config.h.dist b/config.h.dist index 4f31fea..90c224a 100644 --- a/config.h.dist +++ b/config.h.dist @@ -281,11 +281,13 @@ typedef void MySignalHandler; #define DEV_TTY_PATH "/dev/tty" #define CGI_EXTENSION ".cgi" #endif +#define BROTLI_CMDNAME "brotli" #define PATH_SEPARATOR ':' #define GUNZIP_NAME "gunzip" #define BUNZIP2_NAME "bunzip2" #define INFLATE_NAME "inflate" +#define BROTLI_NAME "brotli" #endif /* makefile_parameter */ #endif /* _CONFIGURED_ */ diff --git a/config.h.in b/config.h.in index 6bb0ee0..70e1aef 100644 --- a/config.h.in +++ b/config.h.in @@ -241,11 +241,13 @@ typedef RETSIGTYPE MySignalHandler; #define DEV_TTY_PATH "/dev/tty" #define CGI_EXTENSION ".cgi" #endif +#define BROTLI_CMDNAME "brotli" #define PATH_SEPARATOR ':' #define GUNZIP_NAME "gunzip" #define BUNZIP2_NAME "bunzip2" #define INFLATE_NAME "inflate" +#define BROTLI_NAME "brotli" #ifdef __MINGW32_VERSION #define SIGKILL SIGTERM @@ -161,20 +161,24 @@ static struct compression_decoder { char *name; char *encoding; char *encodings[4]; + int use_d_arg; } compression_decoders[] = { { CMP_COMPRESS, ".gz", "application/x-gzip", 0, GUNZIP_CMDNAME, GUNZIP_NAME, "gzip", - {"gzip", "x-gzip", NULL} }, + {"gzip", "x-gzip", NULL}, 0 }, { CMP_COMPRESS, ".Z", "application/x-compress", 0, GUNZIP_CMDNAME, GUNZIP_NAME, "compress", - {"compress", "x-compress", NULL} }, + {"compress", "x-compress", NULL}, 0 }, { CMP_BZIP2, ".bz2", "application/x-bzip", 0, BUNZIP2_CMDNAME, BUNZIP2_NAME, "bzip, bzip2", - {"x-bzip", "bzip", "bzip2", NULL} }, + {"x-bzip", "bzip", "bzip2", NULL}, 0 }, { CMP_DEFLATE, ".deflate", "application/x-deflate", 1, INFLATE_CMDNAME, INFLATE_NAME, "deflate", - {"deflate", "x-deflate", NULL} }, - { CMP_NOCOMPRESS, NULL, NULL, 0, NULL, NULL, NULL, {NULL}}, + {"deflate", "x-deflate", NULL}, 0 }, + { CMP_BROTLI, ".br", "application/x-br", + 0, BROTLI_CMDNAME, BROTLI_NAME, "br", + {"br", "x-br", NULL}, 1 }, + { CMP_NOCOMPRESS, NULL, NULL, 0, NULL, NULL, NULL, {NULL}, 0}, }; /* *INDENT-ON* */ @@ -8642,6 +8646,7 @@ uncompress_stream(URLFile *uf, char **src) char *tmpf = NULL; char *ext = NULL; struct compression_decoder *d; + int use_d_arg = 0; if (IStype(uf->stream) != IST_ENCODED) { uf->stream = newEncodedStream(uf->stream, uf->encoding); @@ -8655,6 +8660,7 @@ uncompress_stream(URLFile *uf, char **src) expand_cmd = d->cmd; expand_name = d->name; ext = d->ext; + use_d_arg = d->use_d_arg; break; } } @@ -8709,7 +8715,10 @@ uncompress_stream(URLFile *uf, char **src) /* child1 */ dup2(1, 2); /* stderr>&stdout */ setup_child(TRUE, -1, -1); - execlp(expand_cmd, expand_name, NULL); + if (use_d_arg) + execlp(expand_cmd, expand_name, "-d", NULL); + else + execlp(expand_cmd, expand_name, NULL); exit(1); } if (tmpf) { @@ -84,6 +84,7 @@ typedef struct { #define CMP_GZIP 2 #define CMP_BZIP2 3 #define CMP_DEFLATE 4 +#define CMP_BROTLI 5 #define ENC_7BIT 0 #define ENC_BASE64 1 |