Giter Site home page Giter Site logo

Comments (14)

GoogleCodeExporter avatar GoogleCodeExporter commented on July 29, 2024
Poking through the embedding API, I noticed mg_bind_to_error_code().

Perhaps this is already the framework for the feature to be added. 

Add an option to the program for specifying a file to respond with per code, 
and 
then process the option by registering a handler that feeds back the specified 
file, 
and implement the current behaviour as a default should the specified file not 
exist 
or not be available for serving.

Original comment by [email protected] on 22 May 2009 at 8:17

from mongoose.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 29, 2024

Original comment by valenok on 22 May 2009 at 9:18

  • Changed state: Accepted

from mongoose.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 29, 2024
If it isn't too difficult, add a new config option to specify a file to serve 
when
any HTTP error happens (not only 404 but 403 and maybe others). When Mongoose 
calls
the error file (which can be CGI), it should pass the error code as 
REDIRECT_STATUS
in the HTTP header. If you want to pass additional, human-readable, 
information, it
can go in the REDIRECT_ERROR_NOTES header.

Original comment by [email protected] on 23 May 2009 at 1:22

from mongoose.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 29, 2024
The idea is to have a command line option, like:
-error_file 404=404.html,....,0=generic_error.html
For any error code, a file name may be specified. Error code 0 matches any 
error.
And yes, it is a good idea to send those REDIRECT_* headers too.

Original comment by valenok on 23 May 2009 at 5:15

from mongoose.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 29, 2024
I hope when you mentioned a command line option that you would also implement 
it in
the configuration file.

Your approach seems fine to me, although what I had in mind was a "catch-all" 
file
that would handle ANY error, not just those listed in the directive.

Example: -error_file any=error.php

This would serve file error.php, passing it the error information as discussed 
above.

Of course, your idea is better when the user has no CGI interpreter installed. 
Can we
please have both?

Original comment by [email protected] on 23 May 2009 at 5:39

from mongoose.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 29, 2024

  -error_file 404=404.html,0=error.php

0 means wildcard, i.e. all errors that are not listed explicitely will match it.
Also, Mongoose will handle error files according to the file extensions.

For example, with the aboce option, on "500 Internal Server Error" Mongoose 
will show
error.php. Is this be behaviour you are talking about?

Original comment by valenok on 23 May 2009 at 5:51

from mongoose.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 29, 2024
Yes, perfect. Thank you!

By the way, I took a fast look at your code. It's excellent. Good error 
checking. I
like your use of "cry" for error handling. The world is lucky you are making 
this.

Original comment by [email protected] on 23 May 2009 at 6:26

from mongoose.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 29, 2024
But this has been open since May, and not marked "blocked on"...

Original comment by [email protected] on 4 Sep 2010 at 4:07

from mongoose.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 29, 2024

Original comment by valenok on 21 Jun 2011 at 9:11

  • Added labels: Priority-High
  • Removed labels: Priority-Medium

from mongoose.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 29, 2024
any progress on this issue? Would be very useful for my little project AdAway 
(http://code.google.com/p/ad-away)

I am blocking advertisements on android with the hosts file and have bundled 
your webserver to answer request locally to servers that are redirected to 
127.0.0.1

When for example a hostname in the hosts file that serves ads is redirected to 
127.0.0.1 and a website has an iframe with ads in it. There will be an error 
that this iframe can not be loaded. I would like to provide a blank page with 
mongoose instead. For this I could use custom 404 error pages.

Thanks for this wonderful project!

Original comment by [email protected] on 30 Sep 2011 at 8:33

from mongoose.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 29, 2024
@10

plus one


Why can not image requests be answered with an image and document requests be 
answered with a document?


Original comment by [email protected] on 6 Oct 2011 at 12:14

from mongoose.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 29, 2024
Implemented my idea for AdAway using a modified hello.c from the examples. This 
feature requests is no longer important for me.

Thanks for making this webserver.

Original comment by [email protected] on 8 Nov 2011 at 1:27

from mongoose.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 29, 2024
Implemented in the clone at 
https://github.com/GerHobbelt/mongoose/commit/2d37215959dd27363b8be2dd9ab45de0ff
719d54

fix for issue 48: custom error pages. Supports -error_file directory as per 
http://code.google.com/p/mongoose/issues/detail?id=48#c6 . Error files are 
served via the generic mg_produce_nested_page() API - done that way so custom 
event callbacks can (re)use the same logic. Since mg_produce_nested_page() uses 
the internal handle_request() mongoose page serving engine, support for CGI and 
SSI-based error pages is implicit.

The fix also extends the SSI command set with basic support for the SSI 'echo' 
command ( http://www.ssi-developer.net/ssi/ssi-echo.shtml ) so that the 
included sample error pages ( /error/error.shtml and /error/404.html ) can 
print the HTTP response code and accompanying error message text.

Using $E in the error_file URLs is replaced by the error status code, e.g.
  -error_file=404=/error/fnf.html;0=/error/$E.shtml
would try to serve '/error/fnf.html' for a 404 error, and '/error/501.shtml' 
for a 501 error.

Original comment by ger.hobbelt on 14 Jun 2012 at 12:04

from mongoose.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 29, 2024
Pushed 
https://github.com/cesanta/mongoose/commit/5fb275e14651c819b4b2805e4d68680e23114
a20
This utilizes -url_rewrites option: if rewritten URI is a number, it is treated 
as error page.
Example: to redirect all 404 errors to error.cgi, do:

mongoose -url_rewrites 404=/error.cgi

Then, error.cgi will be called with two parameters: error code and original URI:
http://my_server.com/error.cgi?code=404&orig_uri=/dsd

Original comment by valenok on 9 Jan 2014 at 12:41

  • Changed state: Fixed

from mongoose.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.