httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Hu Xuekun" <xueku...@hotmail.com>
Subject [users@httpd] Questions about apache2 module programing
Date Wed, 13 Oct 2004 13:15:49 GMT
hi, 
I am a newbie of apache module programing. I wrote a simple program, but it 
didn't work. 
So I would like someone to give me some suggestions.

The following is  the apache2 module

/* hello.c */
#include "httpd.h"
#include "http_config.h"

static int mod_hello_handler(request_rec *r)
{
        if (strcmp(r->handler, "hello-handler"))
                return DECLINED;

        ap_rputs("<HTML>\n", r);
        ap_rputs("<HEAD>\n", r);
        ap_rputs("<TITLE>Hello World\n", r);
        ap_rputs("</HEAD>\n", r);
        ap_rputs("<BODY>\n", r);
        ap_rputs("Hello World\n", r);
        ap_rputs("</BODY>\n", r);
        ap_rputs("</HTML>\n", r);

        return DECLINED;
}

static void mod_hello_register_hooks (apr_pool_t *p)
{
        ap_hook_handler(mod_hello_handler, NULL, NULL, APR_HOOK_MIDDLE);
}

module AP_MODULE_DECLARE_DATA hello_module =
{
        STANDARD20_MODULE_STUFF,
        NULL,
        NULL,
        NULL,
        NULL,
        NULL,
        mod_hello_register_hooks,
};
/* end of hello.c */

root:# apxs -i -a -n hello -c hello.c
it works.

Then add the following lines in httpd.conf

LoadModule hello_module       modules/hello.so

<Location /hello>
    SetHandler hello-handler
</Location>

Then from client, I use
   http://xxx.xxx.xxx/hello
But it always says" the file didn't exist".

So any comments here?

Thanks.

_________________________________________________________________
与联机的朋友进行交流,请使用 MSN Messenger:  http://messenger.msn.com/cn  


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message