[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[thttpd] patch for SERVER_NAME


  I have a small patch for SERVER_NAME environment variable. I did cgi
application with thttpd and saw that if i don't use vhosts i get SERVER_NAME
equal to hostname of a machine. But it seems wrong.
  For example, user do a http request to my box with uri . This script do the http redirect using
SERVER_NAME, SERVER_PORT and SCRIPT_NAME environment variables. User
get http://mybox/cgi-bin/main.cgi as redirect uri and get "server not found"
page, because mybox resolve to nothing in my home lan.
  In this case, i think, user must get in the http redirect response the same
SERVER_NAME that he entered early.

P.S. I use Debian squeeze
--- thttpd-2.25b.orig/libhttpd.c
+++ thttpd-2.25b/libhttpd.c
@@ -3019,6 +3019,10 @@
     /* If vhosting, use that server-name here. */
     if ( hc->hs->vhost && hc->hostname != (char*) 0 )
 	cp = hc->hostname;
+    else if ( hc->hdrhost[0] != '\0' )
+	cp = hc->hdrhost;
+    else if ( hc->reqhost[0] != '\0' )
+	cp = hc->reqhost;
 	cp = hc->hs->server_hostname;
     if ( cp != (char*) 0 )

Reply to: