h2o / h2o

H2O - the optimized HTTP/1, HTTP/2, HTTP/3 server
https://h2o.examp1e.net
MIT License
10.88k stars 842 forks source link

libh2o output gzip content-encoding #948

Open rajdravid opened 8 years ago

rajdravid commented 8 years ago

Is there any way we can enable gzip encoding for content sent via libh2o ? Can you please provide a sample.

Thanks !

kazuho commented 8 years ago

You should register the output filter to the pathconf by calling h2o_compress_register.

rajdravid commented 8 years ago

Thank you.

rajdravid commented 8 years ago

Sorry leaving this open for others.

Cheurch commented 6 years ago

I don't get it yet. What exactly do I have to do (at least) when starting a server with libh2o to have gzip compression enabled. Is it a built in feature? Is there a (simple!) example? Thank you!

moki commented 4 years ago

@Cheurch

path_conf = h2o_config_register_path(host_conf, "/", 0);
h2o_compress_args_t ca;
h2o_compress_register(path_conf, &ca);
h2o_file_register(path_conf, "static", NULL, NULL,
                            H2O_FILE_FLAG_GUNZIP);

snippet from my simple libh2o server responsible for compressed static assets serving, which is just a slightly modified h2o/examples server. see entire code at https://github.com/moki/simple-libh2o-server