[AOLSERVER] ns_returnerror 404 and redirects

15 views
Skip to first unread message

Fenton, Brian

unread,
Feb 26, 2010, 12:31:26 PM2/26/10
to AOLS...@listserv.aol.com
Hi

I'm looking at using the 404 redirects in AOLserver. There was a recent bug fixed in 4.5.1. where 404s were not redirecting to the config file value e.g.

ns_section ns/server/${server}/redirects
ns_param 404 "/global/file-not-found.adp"

This works great now when I try to access a page that doesn't exist - it redirects nicely to "/global/file-not-found.adp". However, when I make a call to ns_returnerror with a 404 from within a .tcl page, it doesn't redirect to "/global/file-not-found.adp" e.g.

ns_returnerror 404 "This is some error text"

gives me a page saying "Request Error" followed by the text I supplied to ns_returnerror.

Is this expected behaviour i.e. a feature or a bug?

thanks
Brian


--
AOLserver - http://www.aolserver.com/

To Remove yourself from this list, simply send an email to <list...@listserv.aol.com> with the
body of "SIGNOFF AOLSERVER" in the email message. You can leave the Subject: field of your email blank.

Hossein Sharifi

unread,
Feb 26, 2010, 12:54:15 PM2/26/10
to AOLS...@listserv.aol.com

In most cases, you should use ns_returnnotfound to return a 404 error.   I'm pretty sure that the behavior of ns_returnerror is correct and expected.
--
Hossein Sharifi
http://rateyourmusic.com

Fenton, Brian

unread,
Mar 1, 2010, 4:12:01 AM3/1/10
to AOLS...@listserv.aol.com
Hi Hossein

thanks for replying. Sorry, I should have said that it's not just happening with 404s. I tested it with all of the status codes below and none of them redirect. So is it the case that you should only use ns_returnerror with status codes not in the "redirects" parameter list? I'm a little confused.

ns_section ns/server/${server}/redirects
ns_param 404 "/global/file-not-found.adp"

ns_param 403 "/global/forbidden.html"
ns_param 500 "/global/error.adp"
ns_param 503 "/global/error.adp"
ns_param 505 "/global/error.adp"

thanks for the help
Brian

________________________________________
From: AOLserver Discussion [AOLS...@LISTSERV.AOL.COM] On Behalf Of Hossein Sharifi [sha...@RATEYOURMUSIC.COM]
Sent: 26 February 2010 17:54
To: AOLS...@LISTSERV.AOL.COM
Subject: Re: [AOLSERVER] ns_returnerror 404 and redirects

In most cases, you should use ns_returnnotfound to return a 404 error. I'm pretty sure that the behavior of ns_returnerror is correct and expected.

On Fri, Feb 26, 2010 at 6:31 PM, Fenton, Brian <Brian....@quest.ie<mailto:Brian....@quest.ie>> wrote:
Hi

I'm looking at using the 404 redirects in AOLserver. There was a recent bug fixed in 4.5.1. where 404s were not redirecting to the config file value e.g.

ns_section ns/server/${server}/redirects
ns_param 404 "/global/file-not-found.adp"

This works great now when I try to access a page that doesn't exist - it redirects nicely to "/global/file-not-found.adp". However, when I make a call to ns_returnerror with a 404 from within a .tcl page, it doesn't redirect to "/global/file-not-found.adp" e.g.

ns_returnerror 404 "This is some error text"

gives me a page saying "Request Error" followed by the text I supplied to ns_returnerror.

Is this expected behaviour i.e. a feature or a bug?

thanks
Brian

To Remove yourself from this list, simply send an email to <list...@listserv.aol.com<mailto:list...@listserv.aol.com>> with the

Hossein Sharifi

unread,
Mar 1, 2010, 9:51:11 AM3/1/10
to AOLS...@listserv.aol.com
Hi Brian,

Here's how I understand it to work (anyone with more expertise is welcome to chime in).

First of all, the redirects in the config file are only used when:
  1) nsd handles the relevant case directly (for example, a user requests a file that doesn't exist and nsd handles it, using your specified 404 redirect). 
  2) you explicitly call an error proc that is directly related to the error in question.  For example, you handle the "not found" case in your TCL code and call ns_returnnotfound.  You can use ns_returnforbidden to return a 403, ns_returnunauthorized for a 401, etc.  A full list is at http://panoptic.com/wiki/aolserver/Ns_return 

Secondly, the purpose of ns_returnerror is more specific than it might seem at first.  The purpose of that proc is to return a generic "Request Error" page that wraps the error string that you pass in.  It's generally used in the error cases that do not match any of the predefined errors (like filenotfound), but you don't have to use it at all if you don't want; you can just use ns_return with the appropriate status code if you want to specify exactly what is returned. 

So in summary, if you want AOLserver to redirect based on what you've specified in the config file, you must call the specific ns_return function that's related to the type of error.   Although ns_return  and ns_returnerror can be used to return error-related HTTP status codes to the browser, they do not utilize the redirects in the config file.

Regards
Hossein

Tom Jackson

unread,
Mar 1, 2010, 5:15:18 PM3/1/10
to AOLS...@listserv.aol.com
This is just a quick reply.

I think you should remove all 5?? redirects, because unfound files
will cause an error and you get an infinite loop. Your server could
even become unresponsive if someone connects with an unknown METHOD
(not GET, POST, HEAD).

I have a fix, but I haven't really pushed it forward for the community
to look at.

I also wouldn't use an adp 404 message for an error in a tcl file.
There are other config params for errors in adp files.

tom jackson

On Mon, Mar 1, 2010 at 1:12 AM, Fenton, Brian <Brian....@quest.ie> wrote:
> Hi Hossein
>
> thanks for replying. Sorry, I should have said that it's not just happening with 404s. I tested it with all of the status codes below and none of them redirect. So is it the case that you should only use ns_returnerror with status codes not in the "redirects" parameter list? I'm a little confused.
>
> ns_section ns/server/${server}/redirects
> � �ns_param � 404 � � � � � � � �"/global/file-not-found.adp"
> � �ns_param � 403 � � � � � � � �"/global/forbidden.html"
> � �ns_param � 500 � � � � � � � �"/global/error.adp"
> � �ns_param � 503 � � � � � � � �"/global/error.adp"
> � �ns_param � 505 � � � � � � � �"/global/error.adp"
>

Fenton, Brian

unread,
Mar 2, 2010, 4:28:50 AM3/2/10
to AOLS...@listserv.aol.com
Hi Hossein,

thanks for that info - that was very helpful. I was looking at some code that called ns_returnerror. Now I need to dig into why it does what it does as I can see now it just may be calling the wrong thing.

By the way, I'm a HUGE fan of your website. Well done!! I never noticed it was running on AOLserver before. :-)

Brian

________________________________________
From: AOLserver Discussion [AOLS...@listserv.aol.com] On Behalf Of Hossein Sharifi [sha...@RATEYOURMUSIC.COM]
Sent: 01 March 2010 14:51
To: AOLS...@listserv.aol.com


Subject: Re: [AOLSERVER] ns_returnerror 404 and redirects

Hi Brian,

Here's how I understand it to work (anyone with more expertise is welcome to chime in).

First of all, the redirects in the config file are only used when:
1) nsd handles the relevant case directly (for example, a user requests a file that doesn't exist and nsd handles it, using your specified 404 redirect).
2) you explicitly call an error proc that is directly related to the error in question. For example, you handle the "not found" case in your TCL code and call ns_returnnotfound. You can use ns_returnforbidden to return a 403, ns_returnunauthorized for a 401, etc. A full list is at http://panoptic.com/wiki/aolserver/Ns_return

Secondly, the purpose of ns_returnerror is more specific than it might seem at first. The purpose of that proc is to return a generic "Request Error" page that wraps the error string that you pass in. It's generally used in the error cases that do not match any of the predefined errors (like filenotfound), but you don't have to use it at all if you don't want; you can just use ns_return with the appropriate status code if you want to specify exactly what is returned.

So in summary, if you want AOLserver to redirect based on what you've specified in the config file, you must call the specific ns_return function that's related to the type of error. Although ns_return and ns_returnerror can be used to return error-related HTTP status codes to the browser, they do not utilize the redirects in the config file.

Regards
Hossein


On Mon, Mar 1, 2010 at 10:12 AM, Fenton, Brian <Brian....@quest.ie<mailto:Brian....@quest.ie>> wrote:
Hi Hossein

thanks for replying. Sorry, I should have said that it's not just happening with 404s. I tested it with all of the status codes below and none of them redirect. So is it the case that you should only use ns_returnerror with status codes not in the "redirects" parameter list? I'm a little confused.

ns_section ns/server/${server}/redirects
ns_param 404 "/global/file-not-found.adp"
ns_param 403 "/global/forbidden.html"
ns_param 500 "/global/error.adp"
ns_param 503 "/global/error.adp"
ns_param 505 "/global/error.adp"

thanks for the help
Brian

________________________________________
From: AOLserver Discussion [AOLS...@LISTSERV.AOL.COM<mailto:AOLS...@LISTSERV.AOL.COM>] On Behalf Of Hossein Sharifi [sha...@RATEYOURMUSIC.COM<mailto:sha...@RATEYOURMUSIC.COM>]


Sent: 26 February 2010 17:54

To: AOLS...@LISTSERV.AOL.COM<mailto:AOLS...@LISTSERV.AOL.COM>


Subject: Re: [AOLSERVER] ns_returnerror 404 and redirects

In most cases, you should use ns_returnnotfound to return a 404 error. I'm pretty sure that the behavior of ns_returnerror is correct and expected.

On Fri, Feb 26, 2010 at 6:31 PM, Fenton, Brian <Brian....@quest.ie<mailto:Brian....@quest.ie><mailto:Brian....@quest.ie<mailto:Brian....@quest.ie>>> wrote:
Hi

I'm looking at using the 404 redirects in AOLserver. There was a recent bug fixed in 4.5.1. where 404s were not redirecting to the config file value e.g.

ns_section ns/server/${server}/redirects
ns_param 404 "/global/file-not-found.adp"

This works great now when I try to access a page that doesn't exist - it redirects nicely to "/global/file-not-found.adp". However, when I make a call to ns_returnerror with a 404 from within a .tcl page, it doesn't redirect to "/global/file-not-found.adp" e.g.

ns_returnerror 404 "This is some error text"

gives me a page saying "Request Error" followed by the text I supplied to ns_returnerror.

Is this expected behaviour i.e. a feature or a bug?

thanks
Brian

To Remove yourself from this list, simply send an email to <list...@listserv.aol.com<mailto:list...@listserv.aol.com><mailto:list...@listserv.aol.com<mailto:list...@listserv.aol.com>>> with the

Fenton, Brian

unread,
Mar 2, 2010, 4:29:20 AM3/2/10
to AOLS...@listserv.aol.com
Thanks Tom,

that's very good advice. I'll remove those 5xx redirects.

cheers!
Brian
________________________________________
From: AOLserver Discussion [AOLS...@LISTSERV.AOL.COM] On Behalf Of Tom Jackson [t...@RMADILO.COM]
Sent: 01 March 2010 22:15


To: AOLS...@LISTSERV.AOL.COM
Subject: Re: [AOLSERVER] ns_returnerror 404 and redirects

This is just a quick reply.

Reply all
Reply to author
Forward
0 new messages