From 799b8a22e074c59cc635db3a27d5ac73d7dc2a20 Mon Sep 17 00:00:00 2001 From: Unbit Date: Mon, 11 Nov 2013 15:50:11 +0100 Subject: [PATCH] improved content_type detection for rpc-path_info bridge --- plugins/rpc/rpc_plugin.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/rpc/rpc_plugin.c b/plugins/rpc/rpc_plugin.c index aecef9ba..d8ecec8b 100644 --- a/plugins/rpc/rpc_plugin.c +++ b/plugins/rpc/rpc_plugin.c @@ -186,15 +186,15 @@ static int uwsgi_rpc_request(struct wsgi_request *wsgi_req) { uwsgi_404(wsgi_req); return UWSGI_OK; } - if (uwsgi_response_prepare_headers(wsgi_req, "200 OK", 6)) {if (response_buf) free(response_buf); return 1;} - if (uwsgi_response_add_content_length(wsgi_req, content_len)) {if (response_buf) free(response_buf); return 1;} + if (uwsgi_response_prepare_headers(wsgi_req, "200 OK", 6)) {if (response_buf) free(response_buf); return -1;} + if (uwsgi_response_add_content_length(wsgi_req, content_len)) {if (response_buf) free(response_buf); return -1;} uint16_t ctype_len = 0; char *ctype = uwsgi_get_var(wsgi_req, "HTTP_ACCEPT", 11, &ctype_len); - if (ctype && strcmp(ctype, "*/*") && strcmp(ctype, "*")) { - if (uwsgi_response_add_content_type(wsgi_req, ctype, ctype_len)) {if (response_buf) free(response_buf); return 1;} + if (!ctype || !uwsgi_strncmp(ctype, ctype_len, "*/*" ,3) || !uwsgi_strncmp(ctype, ctype_len, "*", 1)) { + if (uwsgi_response_add_content_type(wsgi_req, "application/binary", 18)) {if (response_buf) free(response_buf); return -1;} } else { - if (uwsgi_response_add_content_type(wsgi_req, "application/binary", 18)) {if (response_buf) free(response_buf); return 1;} + if (uwsgi_response_add_content_type(wsgi_req, ctype, ctype_len)) {if (response_buf) free(response_buf); return -1;} } goto sendbody; }