J'apprends à écrire des modules Apache pour un projet sur lequel je travaille. J'ai trouvé le official guide, qui s'avère être très informatif.Y a-t-il plus que GET ou POST pour HTTP?
Sur la première page, "Developing modules for the Apache HTTP Server 2.4", la section "Construire un gestionnaire", sous-section "La structure request_rec
" fournit quelques exemples de code:
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;
}
Quelque chose qui a attiré mon attention était le strcmp
sur r->method
à voir si c'est POST
, GET
, ou quelque chose d'autre. C'est bizarre. Je pensais que les seules méthodes HTTP étaient GET
et POST
? Y a-t-il quelque chose d'autre, ou seulement les développeurs (ou les documenteurs) qui font preuve de prudence?
http://fr.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Request_methods – Blender