 |
HTTP signifie "Hyper Text Transfer Protocol", c'est à dire que c'est le protocole utilisé par les navigateurs web pour
récupérer les pages des serveurs web.
la RFC associée est la 821 (lien vers la RFC en Anglais).
Dans cette page, nous allons vois des exemples de requêtes HTTP, les différentes commandes et les codes de retour.
| Commande | Fonction | Exemple |
| GET |
Envoi une requête de type GET | GET http://www.hobbesworld.com/ HTTP/1.0 |
| POST |
Envoi une requête de type POST | POST /cgi-bin/test.pl HTTP/1.1 |
| HEAD |
Recupère l'en-tête de la requête | HEAD http://www.hobbesworld.com/ HTTP/1.0 |
telnet www.hobbesworld.com 80
HEAD / HTTP/1.1
HTTP/1.1 302 Found
Date: Sun, 11 Jan 2004 23:58:47 GMT
Server: Apache/1.3.20 Sun Cobalt (Unix) mod_throttle/3.1.2 Chili!Soft-ASP/3.6.2 mod_ssl/2.8.4 OpenSSL/0.9.6b PHP/4.1.2 mod_auth_pam_external/0.1 FrontPage/4.0.4.3 mod_perl/1.25
Location: http://www.hobbesworld.com/
Connection: close
Content-Type: text/html; charset=iso-8859-1
telnet www.hobbesworld.com 80
GET /
<HTML><HEAD><meta http-equiv="refresh"
content="0;URL=http://www.amen.fr"></HEAD></HTML>
| | | | | | | | | 3. 3. Exemple de GET en HTTP 1.1
|  |  |  |
|
telnet www.hobbesworld.com 80
GET /hobbesworld.html HTTP/1.1
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*
Accept-Language: fr
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)
Host: 10.10.10.2
Connection: Keep-Alive
HTTP/1.1 200 OK
Date: Wed, 03 Dec 2003 23:58:55 GMT
Server: Apache/2.0.40 (Red Hat Linux)
Last-Modified: Wed, 03 Dec 2003 23:58:43 GMT
ETag: "9c1a4-74-413952c0"
Accept-Ranges: bytes
Content-Length: 116
Connection: close
Content-Type: text/html; charset=ISO-8859-1
<HTML>
<BODY>
Contenu HTML
</BODY>
</HTML>
| | | | | | | | | 3. 4. Exemple de GET en HTTP 1.1 avec envoi d'info
|  |  |  |
|
telnet www.hobbesworld.com 80
GET /cgi-bin/test.pl?testdata=Valeur HTTP/1.1
HOST: 10.10.10.2
HTTP/1.1 200 OK
Date: Wed, 03 Dec 2003 23:39:19 GMT
Server: Apache/2.0.40 (Red Hat Linux)
Connection: close
Transfer-Encoding: chunked
Content-Type: text/html; charset=ISO-8859-1
<HTML>
<BODY>
contenu HTML testdata = Valeur
</BODY>
</HTML>
| | | | | | | | | 3. 5. Exemple de POST basic
|  |  |  |
|
telnet www.hobbesworld.com 80
POST /cgi-bin/test.pl HTTP/1.1
Host: 10.10.10.2
Content-Length: 37
testpost=hobbesworldcestjustepourvoir
HTTP/1.1 200 OK
Date: Wed, 03 Dec 2003 23:53:08 GMT
Server: Apache/2.0.40 (Red Hat Linux)
Content-Length: 66
Connection: close
Content-Type: text/html; charset=ISO-8859-1
<HTML>
<BODY>
contenu HTML testdata = testpost=hobbesworldcestjustepourvoir
</BODY>
</HTML>
| | | | | | | | | 3. 6. Exemple de POST avec en-tête
|  |  |  |
|
telnet www.hobbesworld.com 80
POST /cgi-bin/test.pl HTTP/1.1
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*
Referer: http://10.10.10.2/test.html
Accept-Language: fr
Content-Type: application/x-www-form-urlencoded
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)
Host: 10.10.10.2
Content-Length: 37
Connection: Keep-Alive
Cache-Control: no-cache
testpost=hobbesworldcestjustepourvoir
HTTP/1.1 200 OK
Date: Wed, 03 Dec 2003 23:54:46 GMT
Server: Apache/2.0.40 (Red Hat Linux)
Content-Length: 66
Connection: close
Content-Type: text/html; charset=ISO-8859-1
<HTML>
<BODY>
contenu HTML testdata = testpost=hobbesworldcestjustepourvoir
</BODY>
</HTML>
Pour avoir plus de détails sur les codes de retour HTTP, vous pouvez allez ici :
status HTTP
| Code de retour | Description |
| 100 |
Continue |
| 101 |
Switching Protocols |
| 102 |
Processing |
| 200 |
Ok |
| 201 |
Created |
| 202 |
Accepted |
| 203 |
Non Authoritative |
| 204 |
No Content |
| 205 |
Reset Content |
| 206 |
Partial Content |
| 207 |
Multi Status |
| 300 |
Multiple Choices |
| 301 |
Moved Permanently |
| 302 |
Moved Temporarily |
| 303 |
See Other |
| 304 |
Not Modified |
| 305 |
Use Proxy |
| 307 |
Temporary Redirect |
| 400 |
Bad Request |
| 401 |
Unauthorized |
| 402 |
Payment Required |
| 403 |
Forbidden |
| 404 |
Not Found |
| 405 |
Method Not Allowed |
| 406 |
Not Acceptable |
| 407 |
Proxy Authentication Required |
| 408 |
Request Time Out |
| 409 |
Conflict |
| 410 |
Gone |
| 411 |
Length Required |
| 412 |
Precondition Failed |
| 413 |
Request Entity Too Large |
| 414 |
Request URI Too Large |
| 415 |
Usurpported Media Type |
| 416 |
Range Not Satisfiable |
| 417 |
Expectation Failed |
| 422 |
Unprocessable Entity |
| 423 |
Locked |
| 424 |
Failed Dependency |
| 426 |
Upgrade Required |
| 500 |
Internal Server Error |
| 501 |
Not Implemented |
| 502 |
Bad Gateway |
| 503 |
Service Unavailable |
| 504 |
Gateway Time Out |
| 505 |
Version Not Supported |
| 506 |
Variant Also Varies |
| 507 |
Insufficient Storage |
| 510 |
Not Extended |
en vert : la commande que vous saisissez dans l'outil telnet
en bleu : la réponse à votre commande
|