Apache Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsSystem AdministrationApache Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 13th, 2012, 09:18 AM
deltamind106 deltamind106 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2012
Posts: 3 deltamind106 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 27 m 47 sec
Reputation Power: 0
general - Code to redirect to error doc in output filter module?

I am writing an Apache output filter module that performs basic "text substitutions" on documents. My output filter is working fine, but I want to add a feature that allows my filter to conditionally redirect the request to one of the standard error documents.

For example, in my output filter function, I want to write a line of code that redirects the request to whatever the standard error document is for the "403" (Forbidden) status.

I have successfully used the apr_internal_redirect function to redirect the request to an alternate URI-- this works fine. But what "URI" would I use to redirect to a standard error document?

I tried simply returning the status code HTTP_FORBIDDEN (403) from the output filter function, but that simply causes Apache to serve an "Internal Server Error" document (500).

Thank you in advance for any help you can provide.

Reply With Quote
  #2  
Old December 22nd, 2012, 01:53 PM
jharnois's Avatar
jharnois jharnois is offline
mod_dev_shed
Dev Shed God 20th Plane (14500 - 14999 posts)
 
Join Date: Sep 2002
Location: Atlanta, GA
Posts: 14,817 jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 1 Week 4 Days 7 h 14 m 56 sec
Reputation Power: 1098
So you want to know how to get the 403 ErrorDocument configured for the current context within your output filter so you can redirect to it?

I don't have any experience with filters like this, but it doesn't seem like this is what a filter is designed to do. Maybe you could explain a little about your situation and why you're taking this approach?
__________________
# Jeremy

Explain your problem instead of asking how to do what you decided was the solution.

Reply With Quote
  #3  
Old December 22nd, 2012, 07:58 PM
deltamind106 deltamind106 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2012
Posts: 3 deltamind106 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 27 m 47 sec
Reputation Power: 0
Yes, that sounds like what I want to do. I realize that filters weren't "designed" specifically to do this. But when a fatal error occurs in an output filter, redirecting the request to an error document seems like a reasonable thing to do.

What do you advocate that an output filter should do, when it encounters a fatal error and cannot process the bucket brigade stream? Should it simply pass the bucket brigade through unmodified? That doesn't seem like a good idea, since the user would have no idea there was a problem. Errors are certain to happen, even in output filters, and there must be some way to report to the user that the request can't be processed.

If worst comes to worst, I'll just substitute the entirety of the bucket brigade stream with an error document of my own formation. I was hoping there was a simple way to redirect the request to a standard error document.

Reply With Quote
  #4  
Old December 23rd, 2012, 08:07 PM
jharnois's Avatar
jharnois jharnois is offline
mod_dev_shed
Dev Shed God 20th Plane (14500 - 14999 posts)
 
Join Date: Sep 2002
Location: Atlanta, GA
Posts: 14,817 jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 1 Week 4 Days 7 h 14 m 56 sec
Reputation Power: 1098
I can't find it now, but I ran across some documentation indicating that you can use an external program written in pretty much any language as a filter. Are you doing this or something else?

I would assume (remember, no experience here) Apache calls the filters and has some way of handling a thrown or return error code.

Have you looked at the source of an existing Apache module that acts within the filter chain to see how it handle errors?

Sorry I can't be of more help with this one.

Reply With Quote
  #5  
Old December 23rd, 2012, 09:21 PM
deltamind106 deltamind106 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2012
Posts: 3 deltamind106 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 27 m 47 sec
Reputation Power: 0
My filter is not an external application, but rather a dynamically-linked shared object. It is written in "C", and compiled and linked just like most other Apache "modules". It is listed in the httpd.conf file with a typical "LoadModule" directive.

There is an integer "return value" that I return from the "C" function where the output filter is invoked from Apache. However, returning anything other than "APR_SUCCESS" from this function results in Apache serving the "Internal Server Error" (500) document. It is unfortunate that I can't just return (403) from my filter function and have Apache serve the "Forbidden" error document (I tried and it just doesn't work).

I can look at the source of other filter modules and see what they do. I was hoping that this topic would be "common knowledge" since it seems like such a common requirement.

Thanks for your help.

Reply With Quote
  #6  
Old December 25th, 2012, 03:42 PM
jharnois's Avatar
jharnois jharnois is offline
mod_dev_shed
Dev Shed God 20th Plane (14500 - 14999 posts)
 
Join Date: Sep 2002
Location: Atlanta, GA
Posts: 14,817 jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level)jharnois User rank is General 2nd Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 1 Week 4 Days 7 h 14 m 56 sec
Reputation Power: 1098
I haven't been around in a while, but this forum hasn't historically been good with answering questions related to custom modules The majority of what has gone on here in the past is configuration questions. I'm just not sure we have someone around here who has experience in this kind of thing.

Reply With Quote
Reply

Viewing: Dev Shed ForumsSystem AdministrationApache Development > general - Code to redirect to error doc in output filter module?

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap