diff --git a/plugins/example/example_plugin.c b/plugins/example/example_plugin.c index 37378e3b..c8b705ad 100644 --- a/plugins/example/example_plugin.c +++ b/plugins/example/example_plugin.c @@ -1,23 +1,23 @@ -#include "../../uwsgi.h" +#include extern struct uwsgi_server uwsgi; -int uwsgi_example_init(){ +static int uwsgi_example_init(){ uwsgi_log("i am the example plugin initialization function\n"); return 0; } -int uwsgi_example_request(struct wsgi_request *wsgi_req) { +static int uwsgi_example_request(struct wsgi_request *wsgi_req) { - char *http = "HTTP/1.1 200 Ok\r\nContent-type: text/html\r\n\r\n

Hello World

"; + uwsgi_response_prepare_headers(wsgi_req, "200 OK", 6); + uwsgi_response_add_header(wsgi_req, "Content-type", 12, "text/html", 9); + uwsgi_response_write_body_do(wsgi_req, "

Hello World

", 20); - wsgi_req->response_size += wsgi_req->socket->proto_write(wsgi_req, http, strlen(http)); - - return 0; + return UWSGI_OK; } -void uwsgi_example_after_request(struct wsgi_request *wsgi_req) { +static void uwsgi_example_after_request(struct wsgi_request *wsgi_req) { uwsgi_log("i am the example plugin after request function\n"); } diff --git a/plugins/python/wsgi_handlers.c b/plugins/python/wsgi_handlers.c index c30fbfc3..697895bb 100644 --- a/plugins/python/wsgi_handlers.c +++ b/plugins/python/wsgi_handlers.c @@ -497,10 +497,8 @@ int uwsgi_request_wsgi(struct wsgi_request *wsgi_req) { // LOCK THIS PART - wsgi_req->response_size += wsgi_req->socket->proto_write(wsgi_req, wsgi_req->protocol, wsgi_req->protocol_len); - wsgi_req->response_size += wsgi_req->socket->proto_write(wsgi_req, " 500 Internal Server Error\r\n", 28 ); - wsgi_req->response_size += wsgi_req->socket->proto_write(wsgi_req, "Content-type: text/plain\r\n\r\n", 28 ); - wsgi_req->header_cnt = 1; + uwsgi_500(wsgi_req); + uwsgi_response_write_headers_do(wsgi_req); /* sorry that is a hack to avoid the rewrite of PyErr_Print