mirror of
https://github.com/clearlinux/uwsgi.git
synced 2026-09-06 13:41:28 +00:00
added transformation_gzip
This commit is contained in:
@@ -589,6 +589,8 @@ void uwsgi_close_request(struct wsgi_request *wsgi_req) {
|
||||
// send the body only if transformations are successfull
|
||||
struct uwsgi_buffer *ub = wsgi_req->response_buffer;
|
||||
if (uwsgi_apply_transformations(wsgi_req) == 0) {
|
||||
// teh response_buffer could be changed
|
||||
ub = wsgi_req->response_buffer;
|
||||
// force true write
|
||||
wsgi_req->response_buffer = NULL;
|
||||
uwsgi_response_write_body_do(wsgi_req, ub->buf, ub->pos);
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
#include <uwsgi.h>
|
||||
|
||||
static int transform_gzip(struct wsgi_request *wsgi_req, struct uwsgi_buffer *ub, struct uwsgi_buffer **new) {
|
||||
struct uwsgi_buffer *gzipped = uwsgi_gzip(ub->buf, ub->pos);
|
||||
if (!gzipped) {
|
||||
return -1;
|
||||
}
|
||||
// use this new buffer
|
||||
*new = gzipped;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int uwsgi_routing_func_gzip(struct wsgi_request *wsgi_req, struct uwsgi_route *ur) {
|
||||
uwsgi_add_transformation(wsgi_req, transform_gzip);
|
||||
return UWSGI_ROUTE_NEXT;
|
||||
}
|
||||
|
||||
static int uwsgi_router_gzip(struct uwsgi_route *ur, char *args) {
|
||||
ur->func = uwsgi_routing_func_gzip;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void router_gzip_register(void) {
|
||||
uwsgi_register_router("gzip", uwsgi_router_gzip);
|
||||
}
|
||||
|
||||
struct uwsgi_plugin transformation_gzip_plugin = {
|
||||
.name = "transformation_gzip",
|
||||
.on_load = router_gzip_register,
|
||||
};
|
||||
@@ -0,0 +1,6 @@
|
||||
NAME='transformation_gzip'
|
||||
|
||||
CFLAGS = []
|
||||
LDFLAGS = []
|
||||
LIBS = []
|
||||
GCC_LIST = ['gzip']
|
||||
Reference in New Issue
Block a user