From c04513f8bd56b27f263a7a1909c7ac3b2174bdff Mon Sep 17 00:00:00 2001 From: "roberto@debian32" Date: Fri, 29 Jul 2011 06:13:50 +0200 Subject: [PATCH] fixed SERVER_PORT in http protocol handler --- proto/http.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/proto/http.c b/proto/http.c index 27e1d98c..962eb2b1 100644 --- a/proto/http.c +++ b/proto/http.c @@ -146,7 +146,13 @@ static int http_parse(struct wsgi_request *wsgi_req, char *watermark) { wsgi_req->uh.pktsize += proto_base_add_uwsgi_var(wsgi_req, "SERVER_NAME", 11, uwsgi.hostname, uwsgi.hostname_len); // SERVER_PORT - wsgi_req->uh.pktsize += proto_base_add_uwsgi_var(wsgi_req, "SERVER_PORT", 11, "3031", 4); + char *server_port = strchr(wsgi_req->socket->name, ':'); + if (server_port) { + wsgi_req->uh.pktsize += proto_base_add_uwsgi_var(wsgi_req, "SERVER_PORT", 11, server_port+1, strlen(server_port+1)); + } + else { + wsgi_req->uh.pktsize += proto_base_add_uwsgi_var(wsgi_req, "SERVER_PORT", 11, "80", 2); + } // REMOTE_ADDR memset(ip, 0, INET_ADDRSTRLEN+1);