我正在学习编写我正在开发的项目的Apache模块。我发现official guide,原来是很资料。HTTP是否有GET或POST?
在第一页上,“Developing modules for the Apache HTTP Server 2.4”,部分“建立一个处理程序”,第“的request_rec
结构”提供了一些示例代码:
static int example_handler(request_rec *r)
{
/* Set the appropriate content type */
ap_set_content_type(r, "text/html");
/* Print out the IP address of the client connecting to us: */
ap_rprintf(r, "<h2>Hello, %s!</h2>", r->useragent_ip);
/* If we were reached through a GET or a POST request, be happy, else sad. */
if (!strcmp(r->method, "POST") || !strcmp(r->method, "GET")) {
ap_rputs("You used a GET or a POST method, that makes us happy!<br/>", r);
}
else {
ap_rputs("You did not use POST or GET, that makes us sad :(<br/>", r);
}
/* Lastly, if there was a query string, let's print that too! */
if (r->args) {
ap_rprintf(r, "Your query string was: %s", r->args);
}
return OK;
}
东西引起了我的眼睛是strcmp
上r->method
到看看它是POST
,GET
或别的东西。这很奇怪。我认为唯一的HTTP方法是GET
和POST
?还有其他的东西,还是仅仅是开发者(或者说记录者)非常谨慎?
http://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Request_methods – Blender