Forum

/ Home \ \ Subjects /



Subject: Strange behavior when loading 404 page

13/06/2009 21:12 Carlos:
Hello, Max

I'm experiencing a strange behavior when loading my configured 404 page.

----

1)
I cannot connect to a mySQL database from the specific 404 page, due to socket error 'mysql Can't create TCP/IP socket (10106)'. I guess I wouldn't be able to create any socket either.

2)
The next server variables have wrong values:

$_SERVER[ORIG_PATH_INFO] is one character less than the right value. For example, instead of 'c:/my/path', it is: '/c:/my/pat'. I think the blame is on the initial slash.

3)
PHP_SELF and ORIG_SCRIPT_NAME also get weird values:

$_SERVER[PHP_SELF] => ident="/application/
$_SERVER[ORIG_SCRIPT_NAME] => ident="/application/

4)
If the wrong url (the one which caused the 404 page to be shown) is "short", the $_SERVER variable is populated with a small set of values:

GATEWAY_INTERFACE, REQUEST_METHOD, SERVER_PROTOCOL, REMOTE_HOST, SERVER_SOFTWARE, SCRIPT_FILENAME, SCRIPT_NAME, ORIG_PATH_TRANSLATED, ORIG_PATH_INFO, ORIG_SCRIPT_NAME, ORIG_SCRIPT_FILENAME, PHP_SELF, REQUEST_TIME

But if the url is "long", the $_SERVER variable is populated with a much bigger set of values:

GATEWAY_INTERFACE, REQUEST_METHOD, SERVER_PROTOCOL, REMOTE_HOST, SERVER_SOFTWARE, SCRIPT_FILENAME, SCRIPT_NAME, USER_AGENT, HTTP_USER_AGENT, ACCEPT, HTTP_ACCEPT, ACCEPT_LANGUAGE, HTTP_ACCEPT_LANGUAGE, ACCEPT_ENCODING, HTTP_ACCEPT_ENCODING, ACCEPT_CHARSET, HTTP_ACCEPT_CHARSET, KEEP_ALIVE, HTTP_KEEP_ALIVE, CONNECTION, HTTP_CONNECTION, COOKIE, HTTP_COOKIE, DATE_GMT, HTTP_DATE_GMT, DATE_LOCAL, HTTP_DATE_LOCAL, QUERY_STRING, HTTP_QUERY_STRING, SERVER_PORT, HTTP_SERVER_PORT, REMOTE_ADDR, HTTP_REMOTE_ADDR, REMOTE_COUNTRY, HTTP_REMOTE_COUNTRY, ALLUSERSPROFILE, APPDATA, CLIENTNAME, CommonProgramFiles, COMPUTERNAME, ComSpec, FP_NO_HOST_CHECK, HOMEDRIVE, HOMEPATH, LOGONSERVER, NUMBER_OF_PROCESSORS, OS, Path, PATHEXT, PROCESSOR_ARCHITECTURE, PROCESSOR_IDENTIFIER, PROCESSOR_LEVEL, PROCESSOR_REVISION, ProgramFiles, SESSIONNAME, SystemDrive, SystemRoot, TEMP, USERDOMAIN, U
13/06/2009 21:13 Carlos:
My previous message got truncated:

But if the url is "long", the $_SERVER variable is populated with a much bigger set of values:

GATEWAY_INTERFACE, REQUEST_METHOD, SERVER_PROTOCOL, REMOTE_HOST, SERVER_SOFTWARE, SCRIPT_FILENAME, SCRIPT_NAME, USER_AGENT, HTTP_USER_AGENT, ACCEPT, HTTP_ACCEPT, ACCEPT_LANGUAGE, HTTP_ACCEPT_LANGUAGE, ACCEPT_ENCODING, HTTP_ACCEPT_ENCODING, ACCEPT_CHARSET, HTTP_ACCEPT_CHARSET, KEEP_ALIVE, HTTP_KEEP_ALIVE, CONNECTION, HTTP_CONNECTION, COOKIE, HTTP_COOKIE, DATE_GMT, HTTP_DATE_GMT, DATE_LOCAL, HTTP_DATE_LOCAL, QUERY_STRING, HTTP_QUERY_STRING, SERVER_PORT, HTTP_SERVER_PORT, REMOTE_ADDR, HTTP_REMOTE_ADDR, REMOTE_COUNTRY, HTTP_REMOTE_COUNTRY, ALLUSERSPROFILE, APPDATA, CLIENTNAME, CommonProgramFiles, COMPUTERNAME, ComSpec, FP_NO_HOST_CHECK, HOMEDRIVE, HOMEPATH, LOGONSERVER, NUMBER_OF_PROCESSORS, OS, Path, PATHEXT, PROCESSOR_ARCHITECTURE, PROCESSOR_IDENTIFIER, PROCESSOR_LEVEL, PROCESSOR_REVISION, ProgramFiles, SESSIONNAME, SystemDrive, SystemRoot, TEMP, USERDOMAIN, USERNAME, USERPROFILE, windir, ORIG_PATH_TRANSLATED, ORIG_PATH_INFO, ORIG_SCRIPT_NAME, ORIG_SCRIPT_FILENAME, PHP_SELF, REQUEST_TIME

The $_COOKIE variable is also populated (if the url is "short", $_COOKIE is empty).

Also, when the url is "long",

$_SERVER[PHP_SELF] => cgi_ident="/application/
$_SERVER[SCRIPT_NAME] => cgi_ident="/application/

----

I'm using Small HTTP Server version 3.05.85.

By the way, my "CGI ident" option is set to "\application\" in the server configuration.

I tried to calculate the number of characters in the url that makes the url "short" or "long", but it depends on the virtual host.

That's all. Please tell me if any of this make any sense to you.

Thank you in advance.


Carlos

17/06/2009 18:38 Max:
1) Connection with SQL server is independent from HTTP server.
2,4) The server doesn't set ORIG_* and PHP_SELF -- probably it is PHP feature.

The server manage memory required for enviroment variables and in some cases it decline some useless variables, for save system resurces and for fast work.

You may ditrect all vars that doesn't supported by server but that need for you in system enviroment before server run.

Thank you for your message, I will check and fix the strip of last char that you describe in 2).

18/06/2009 01:16 Carlos_:
Thank you very much for your reply, Max.

I don't actually need *all* those system variables. The fact is that I am developing a 404-error PHP script that records every 'Not found' hit on my database, so I can find out and fix broken links at my site.

That's why I really need the standard CGI environment variables (hoohoo.ncsa.illinois.edu/cgi/env .. or at least: PATH_INFO, PATH_TRANSLATED, SCRIPT_NAME, QUERY_STRING; and having HTTP_REFERER available too would come in handy.

Do you think that the server *really* needs to get rid of those 'useless' variables? Because they would be very useful for me.

18/06/2009 18:38 Max:
In current versions, when the server will run error file, "QUERY_STRING" variable will contents the name of requested file.

19/06/2009 01:54 Carlos_:
I am really grateful for your quick solution.

The specification states that QUERY_STRING is only "the information which follows the question mark in the URL", but I am absolutely fine with this decision for the 404 error page.

I am looking forward to the next version. Just for curiousity, are you planning to include the HTTP referrer, too?

Thanks again for your help.


User: Password: New user:   Save password: