ajout d'infos
This commit is contained in:
parent
4c6225bfc0
commit
12271d648a
107
HowtoHTTP.md
107
HowtoHTTP.md
|
@ -1,12 +1,12 @@
|
||||||
# Howto HTTP
|
# Howto HTTP
|
||||||
|
|
||||||
Le procotole HTTP (HyperText Transfer Protocol) est un protocole client/serveur de niveau 7 s'appuyant par convention sur la couche de transport TCP et le port 80. Sa version sécurisée est HTTPS qui s'appuye en plus sur la couche [SSL/TLS](HowtoSSL).
|
Le procotole HTTP (HyperText Transfer Protocol) est un protocole client/serveur de niveau 7 s'appuyant par convention sur la couche de transport TCP et le port 80. Sa version sécurisée est HTTPS qui ajoute la couche [SSL/TLS](HowtoSSL).
|
||||||
|
|
||||||
## Comprendre les différentes versions de HTTP grâce à telnet
|
## Comprendre les différentes versions de HTTP grâce à telnet
|
||||||
|
|
||||||
### HTTP/1.0
|
### HTTP/1.0
|
||||||
|
|
||||||
La version la plus simple, ll'entête `Host:` est facultatif :
|
La version la plus simple, l'entête `Host:` est facultatif :
|
||||||
|
|
||||||
~~~
|
~~~
|
||||||
$ telnet www.debian.org 80
|
$ telnet www.debian.org 80
|
||||||
|
@ -103,18 +103,104 @@ Server: Apache
|
||||||
|
|
||||||
### HTTP/2.0
|
### HTTP/2.0
|
||||||
|
|
||||||
<https://fr.wikipedia.org/wiki/Hypertext_Transfer_Protocol/2>
|
Voir <https://fr.wikipedia.org/wiki/Hypertext_Transfer_Protocol/2>
|
||||||
|
|
||||||
|
|
||||||
## Outils
|
## Outils HTTP
|
||||||
|
|
||||||
### HEAD/GET/POST
|
### Commandes HEAD/GET/POST
|
||||||
|
|
||||||
|
Il s'agit de commandes HEAD, GET, POST faisant partie de la bibliothèque LWP (WWW Library for Perl) :
|
||||||
|
|
||||||
~~~
|
~~~
|
||||||
# apt install libwww-perl
|
# apt install libwww-perl
|
||||||
~~~
|
~~~
|
||||||
|
|
||||||
Voir <http://gcolpart.evolix.net/blog21/faire-du-postgethead-en-ligne-de-commande/>
|
Utilisation :
|
||||||
|
|
||||||
|
~~~
|
||||||
|
$ HEAD www.evolix.fr
|
||||||
|
200 OK
|
||||||
|
Connection: close
|
||||||
|
Date: Tue, 28 Dec 2010 20:08:35 GMT
|
||||||
|
Server: Apache
|
||||||
|
Vary: Accept-Encoding
|
||||||
|
Content-Type: text/html
|
||||||
|
Client-Date: Tue, 28 Dec 2010 20:08:44 GMT
|
||||||
|
Client-Peer: 85.31.205.43:80
|
||||||
|
Client-Response-Num: 1
|
||||||
|
|
||||||
|
$ GET -Sd evolix.fr
|
||||||
|
GET http://evolix.fr
|
||||||
|
301 Moved Permanently
|
||||||
|
GET http://www.evolix.fr/
|
||||||
|
301 Moved Permanently
|
||||||
|
GET http://evolix.com/
|
||||||
|
200 OK
|
||||||
|
|
||||||
|
$ HEAD -U -H "User-Agent: Mozilla/4.8 [en] (Windows NT 5.1; fr; rv:BlogByGcolpart)" \
|
||||||
|
-H "Referer: http://www.evolix.fr/" www.evolix.fr/serv/infogerance.html
|
||||||
|
HEAD http://www.evolix.fr/serv/infogerance.html
|
||||||
|
Referer: http://www.evolix.fr/
|
||||||
|
User-Agent: Mozilla/4.8 [en] (Windows NT 5.1; fr; rv:BlogByGcolpart)
|
||||||
|
|
||||||
|
200 OK
|
||||||
|
Connection: close
|
||||||
|
Date: Thu, 13 Jan 2011 23:14:13 GMT
|
||||||
|
Server: Apache
|
||||||
|
Vary: Accept-Encoding
|
||||||
|
Content-Type: text/html
|
||||||
|
Client-Date: Thu, 13 Jan 2011 23:14:13 GMT
|
||||||
|
Client-Peer: 85.31.205.43:80
|
||||||
|
Client-Response-Num: 1
|
||||||
|
|
||||||
|
$ GET -dUe google.fr
|
||||||
|
GET http://www.google.fr/
|
||||||
|
User-Agent: lwp-request/6.03 libwww-perl/6.08
|
||||||
|
|
||||||
|
200 OK
|
||||||
|
Cache-Control: private, max-age=0
|
||||||
|
Connection: close
|
||||||
|
Date: Thu, 18 May 2017 12:00:13 GMT
|
||||||
|
Accept-Ranges: none
|
||||||
|
Server: gws
|
||||||
|
Vary: Accept-Encoding
|
||||||
|
Content-Type: text/html; charset=ISO-8859-1
|
||||||
|
Expires: -1
|
||||||
|
Client-Date: Thu, 18 May 2017 12:00:13 GMT
|
||||||
|
Client-Peer: 216.58.210.195:80
|
||||||
|
Client-Response-Num: 1
|
||||||
|
Link: </images/branding/product/ico/googleg_lodp.ico>; rel="shortcut icon"
|
||||||
|
P3P: CP="This is not a P3P policy! See https://www.google.com/support/accounts/answer/151657?hl=en for more info."
|
||||||
|
Set-Cookie: NID=103=UEe-aKr4jwguVRZw_irgQQo6WviJ2ZArnM9iCouDcPzBV_RZk4YiR4I13Kn1JSO-Gbcowcw5W1BtUTCd7pQt7H6_zKK6zf8EVb2GG5Yb_ariD0aWeAJxHFf2sRMkZXTi; expires=Fri, 17-Nov-2017 12:00:13 GMT; path=/; domain=.google.fr; HttpOnly
|
||||||
|
Title: Google
|
||||||
|
X-Frame-Options: SAMEORIGIN
|
||||||
|
X-XSS-Protection: 1; mode=block
|
||||||
|
|
||||||
|
$ GET http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.36.2.tar.bz2 > linux-2.6.36.2.tar.bz2
|
||||||
|
|
||||||
|
$ GET google.fr | grep charset= | sed 's@^.*charset=\([-a-Z0-9]*\)".*$@\1@'
|
||||||
|
ISO-8859-1
|
||||||
|
|
||||||
|
$ POST http://www.evolix.fr/contacts.html
|
||||||
|
Please enter content (application/x-www-form-urlencoded) to be POSTed:
|
||||||
|
from=jdoe%40example.com&contenu=Coucou&validation=nospam&soumettre=ok
|
||||||
|
Ctrl+d
|
||||||
|
|
||||||
|
$ echo -n "from=jdoe%40example.com&contenu=Coucou&validation=nospam&soumettre=ok" > /tmp/POST-DATA.txt
|
||||||
|
$ POST http://www.evolix.fr/contacts.html < /tmp/POST-DATA.txt
|
||||||
|
~~~
|
||||||
|
|
||||||
|
Note : Attention, pour envoyer interactivement des données en POST, il faut ensuite les valider avec Ctrl+d
|
||||||
|
|
||||||
|
Voici les différentes options possibles :
|
||||||
|
|
||||||
|
|
||||||
|
* `-U` : affiche les entêtes envoyés
|
||||||
|
* `-e` : affiche les entêtes reçus (s'utilise avec GET/POST car c'est le défaut pour HEAD)
|
||||||
|
* `-d` : ne pas afficher la réponse (à utiliser avec `-dUe` ou `-dS` par exemple)
|
||||||
|
* `-H` : envoyer un entête HTTP particulier
|
||||||
|
* `-S` : affiche les redirections HTTP suivies
|
||||||
|
|
||||||
### wget
|
### wget
|
||||||
|
|
||||||
|
@ -144,9 +230,10 @@ Voici les différentes options possibles :
|
||||||
|
|
||||||
### cURL
|
### cURL
|
||||||
|
|
||||||
[cURL](https://curl.haxx.se/) est un autre client HTTP en ligne de commande.
|
[cURL](https://curl.haxx.se/) est aussi un client HTTP en ligne de commande.
|
||||||
|
|
||||||
|
Voir [HowtocURL]()
|
||||||
|
|
||||||
Voir [TipsCurl]() pour plus de détails.
|
|
||||||
|
|
||||||
### ab : apache bench
|
### ab : apache bench
|
||||||
|
|
||||||
|
@ -164,3 +251,7 @@ $ ab -n 1000 -c 100 -l http://127.0.0.1/helloworld.txt
|
||||||
* `-c` : nombre de requêtes effectuées en simultané
|
* `-c` : nombre de requêtes effectuées en simultané
|
||||||
* `-l` : option importante qui tolère la variation de la réponse du serveur (si non, les requêtes seront notées en *Failed requests*)
|
* `-l` : option importante qui tolère la variation de la réponse du serveur (si non, les requêtes seront notées en *Failed requests*)
|
||||||
* `-k` : active le HTTP KeepAlive
|
* `-k` : active le HTTP KeepAlive
|
||||||
|
|
||||||
|
### Tsung
|
||||||
|
|
||||||
|
Voir [HowtoTsung]()
|
||||||
|
|
Loading…
Reference in a new issue