programmation_http
HTTP
Liens:
Vu sous l'angle du protocole et de la programmation.
get
HTTP 0
Simple:
$ echo "GET /" | nc thierry-jaouen.fr 80 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <html><head> <title>301 Moved Permanently</title> </head><body> <h1>Moved Permanently</h1> <p>The document has moved <a href="http://www.thierry-jaouen.fr">here</a>.</p> </body></html>
Pareil mais en plus precis:
$ echo -n -e "GET /\n" | nc thierry-jaouen.fr 80
HTTP 1
Mais tout le monde parle en HTTP 1 de nos jours… donc:
$ echo -n -e "GET / HTTP/1.0\n\n" | nc thierry-jaouen.fr 80 HTTP/1.1 301 Moved Permanently Date: Fri, 22 Jan 2010 12:18:02 GMT Server: Apache/2.2.9 (Debian) PHP/5.2.6-1+lenny4 with Suhosin-Patch mod_ssl/2.2.9 OpenSSL/0.9.8g mod_musicindex/1.2.2 mod_perl/2.0.4 Perl/v5.10.0 Location: http://www.thierry-jaouen.fr Content-Length: 236 Connection: close Content-Type: text/html; charset=iso-8859-1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <html><head> <title>301 Moved Permanently</title> </head><body> <h1>Moved Permanently</h1> <p>The document has moved <a href="http://www.thierry-jaouen.fr">here</a>.</p> </body></html>
Ce qui retourne un peu plus d'information sur le serveur HTTP.
host
Changez d'“hote” (le nom de la machine qu'on vise derrière l'ip unique)…
Par exemple, on veut atteindre l'hôte dvdrip.fr
:
$ echo -n -e "GET / HTTP/1.0\nHost: dvdrip.fr\n\n" | nc thierry-jaouen.fr 80 HTTP/1.1 302 Found Date: Fri, 22 Jan 2010 12:21:28 GMT Server: Apache/2.2.9 (Debian) PHP/5.2.6-1+lenny4 with Suhosin-Patch mod_ssl/2.2.9 OpenSSL/0.9.8g mod_musicindex/1.2.2 mod_perl/2.0.4 Perl/v5.10.0 Location: http://dvdrip.fr/dvdrip.html Content-Length: 213 Connection: close Content-Type: text/html; charset=iso-8859-1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <html><head> <title>302 Found</title> </head><body> <h1>Found</h1> <p>The document has moved <a href="http://dvdrip.fr/dvdrip.html">here</a>.</p> </body></html>
programmation_http.txt · Dernière modification : 2010/09/24 14:32 de thierry