On Friday 11 February 2005 06:02, Dossy Shiobara wrote:
> I have two proposed changes:
>
> 1) Allow overriding of all response codes. This may not actually be a
> good idea, but it just seems odd that only certain response codes
> have their own C API which uses the internal redirect mechanism.
>
> 2) The current internal redirect mechanism changes the URL in the
> request then re-executes it. The downside of the current
> implementation is that a custom error handler for 500 Server Error,
> if it's defined and exists and is served, turns the request into a
> 200 OK. The HTTP response becomes a 200 OK instead of the original
> 500 Server Error with the custom HTTP response body. nslog also logs
> a 200 OK in the access log, instead of the 500. This just feels
> wrong to me. If you have a custom 404 page, you can't use the access
> log to report on the number of 404's any more since the log will show
> 200's for the 404 requests.
>
>
> I'm still on the fence whether #1 is a good idea or not. In principle
> it's the right thing to do, but implementing it properly will require a
> lot of refactoring of nsd/return.c to make it clean, and even then
> there could be problems.
>
>
> I'm definitely in favor of making the chnage described in #2, however
> it's a functionality change that will invalidate people's assumptions
> who use internal redirects and I don't know what effect that will have
> on people's applications, especially logfile analyzers, etc. I'm keen
> on implementing this change for 4.1.0, but what I really want to know is
> do people think it's okay to backport this change to 4.0.x? I really
> want to, but if everyone else thinks it's a bad idea ... then I can
> leave it as a 4.1.0-only change.
My Config file contains:
#
# Server url, Proxy & Redirects
ns_section "ns/server/${server}/redirects"
ns_param 404 "global/file-not-found.tcl"
ns_param 500 "global/server-error.tcl"
The file-not-found.tcl page contains:
set request [ns_conn request]
set url [lindex [split $request] 1]
set path $url
set full_path [ns_url2file $url]
if {![string equal "/" "$path"] && [file isdirectory "$full_path"]} {
css_dirlist $full_path $path
} else {
ns_returnnotice 404 "Not Found" "File $path Not Found"
}
Which provides a directory listing (I think this was developed for OACS,
otherwise AOLserver can do the directory listing itself). Anyway, a telnet
request of the url adds this to the access.log:
192.168.111.100 - - [11/Feb/2005:08:43:54 -0800] "GET /xyz HTTP/1.0" 404 539
"" ""
and the response to the client is:
HTTP/1.0 404 Not Found
Server: AOLserver/4.0.10
...etc.
I did a similar test with 500. I created a page containing 'error'.
server-error.tcl contains:
global errorInfo
ns_return 500 text/plain "Oops screwed up: $errorInfo"
The access.log entry contains:
192.168.111.100 - - [11/Feb/2005:08:58:06 -0800] "GET /global/test.tcl
HTTP/1.0" 500 257 "" ""
So I guess if you have a custom handler, it becomes responsible for the
response. In fact in the first case, you want the response to change to 200
if the request was for a directory which exists. It looks like the programmer
still has complete control over what response gets sent, as long as they
handle the request with a script.
tom jackson
--
AOLserver - http://www.aolserver.com/
To Remove yourself from this list, simply send an email to <[EMAIL PROTECTED]>
with the
body of "SIGNOFF AOLSERVER" in the email message. You can leave the Subject:
field of your email blank.