Retour à la liste de TP CR TP2 TechnoWeb (Protocole HTTP 1.1)

Le fruit d'une association sans faille de Bogdan et Laurent, mieux connus sous le nom de "Smeckers"...

Légende: entre <kbd></kdb>, les lignes de commande entrées. Entre <var></var>, la réponse du serveur. Le reste <code></code> est du code ou shell sans grand intérêt.

Test de connexion simple et de récupération d'une page:

[obogdan@asi1246 obogdan]$ telnet www.serveurperso.com 80
Trying 212.194.183.136...
Connected to www.serveurperso.com.
Escape character is '^]'.

GET /index.php HTTP/1.1
Host: www.serveurperso.com

HTTP/1.1 200 OK
Date: Tue, 11 Feb 2003 09:13:21 GMT
Server: Apache/1.3.27 (Win32) PHP/4.3.0
X-Powered-By: PHP/4.3.0
Transfer-Encoding: chunked
Content-Type: text/html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<TITLE>
Serveur perso ! - serveurperso.com
</TITLE>
......
......
</HTML>

  1. Rapatrier la page si elle a été modifiée depuis cette date:

    GET /~obogdan/index.html HTTP/1.1
    Host: asi.insa-rouen.fr
    If-Modified-Since: Thu, 06 Feb 2003 01:00:00 GMT

    HTTP/1.1 200 OK
    Date: Mon, 03 Mar 2003 23:22:29 GMT
    Server: Apache/1.3.22 (Unix) (Red-Hat/Linux) PHP/4.1.2
    Last-Modified: Thu, 06 Feb 2003 23:11:28 GMT
    ETag: "1bc3a9-594-3e42eba0"
    Accept-Ranges: bytes
    Content-Length: 1428
    Connection: close
    Content-Type: text/html

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    ....
    </html>

    GET /~obogdan/index.html HTTP/1.1
    Host: asi.insa-rouen.fr
    If-Modified-Since: Thu, 06 Feb 2003 23:12:59 GMT

    HTTP/1.1 304 Not Modified
    Date: Mon, 03 Mar 2003 23:25:48 GMT
    Server: Apache/1.3.22 (Unix) (Red-Hat/Linux) PHP/4.1.2
    Connection: close
    ETag: "1bc3a9-594-3e42eba0"

    La page n'a pas été modifiée depuis la date indiqué dans la requête, le serveur nous répond en 304.

  2. Requête pour obtenir les caractères 2 à 10 d'une page:

    GET /~obogdan/index.html HTTP/1.1
    Host: asi.insa-rouen.fr
    Range: bytes=2-10

    HTTP/1.1 206 Partial Content
    Date: Tue, 11 Feb 2003 10:59:29 GMT
    Server: Apache/1.3.22 (Unix) (Red-Hat/Linux) PHP/4.0.6
    Last-Modified: Thu, 06 Feb 2003 23:11:28 GMT
    ETag: "1bc3a9-594-3e42eba0"
    Accept-Ranges: bytes
    Content-Length: 9
    Content-Range: bytes 2-10/1428
    Connection: close
    Content-Type: text/html

    DOCTYPE HConnection closed by foreign host.

    La réponse du serveur est bien d'une longueur de 9 octets "DOCTYPE H".

  3. Ecrire une requête effectuant une négociation sur le type de média demandé

    HEAD /~lfallet/logo_asi HTTP/1.1
    Host: asi.insa-rouen.fr
    Accept: image/gif; q=1, image/png; q=0.2

    HTTP/1.1 200 OK
    Date: Sun, 09 Mar 2003 21:45:49 GMT
    Server: Apache/1.3.22 (Unix) (Red-Hat/Linux) PHP/4.1.2
    Content-Location: logo_asi.gif
    Vary: negotiate,accept
    TCN: choice
    Last-Modified: Sun, 09 Mar 2003 21:45:12 GMT
    ETag: "c43d4-21e3-3e6bb5e8;3e6bb5e8"
    Accept-Ranges: bytes
    Content-Length: 8675
    Connection: close
    Content-Type: image/gif

    HEAD /~lfallet/logo_asi HTTP/1.1
    Host: asi.insa-rouen.fr
    Accept: image/png; q=0.8, image/gif; q=0.4

    HTTP/1.1 200 OK
    Date: Sun, 09 Mar 2003 21:49:14 GMT
    Server: Apache/1.3.22 (Unix) (Red-Hat/Linux) PHP/4.1.2
    Content-Location: logo_asi.png
    Vary: negotiate,accept
    TCN: choice
    Last-Modified: Sun, 09 Mar 2003 21:45:12 GMT
    ETag: "c43d5-16e5-3e6bb5e8;3e6bb5e8"
    Accept-Ranges: bytes
    Content-Length: 5861
    Connection: close
    Content-Type: image/png

  4. Ecrire une requête avec négociation de contenu sur la langue:

    GET / HTTP/1.1
    Host: www.debian.org
    Accept-Language: da;q=0.8, fr;q=0.5

    HTTP/1.1 200 OK
    Date: Mon, 03 Mar 2003 23:03:31 GMT
    Server: Apache/1.3.26 (Unix) Debian GNU/Linux PHP/4.1.2
    Content-Location: index.da.html
    Vary: negotiate,accept-language
    TCN: choice
    Cache-Control: max-age=86400
    Expires: Tue, 04 Mar 2003 23:03:31 GMT
    Last-Modified: Mon, 03 Mar 2003 22:32:53 GMT
    ETag: "1113c2-3f24-3e63d815;3e63dbd9"
    Accept-Ranges: bytes
    Content-Length: 16164
    Content-Type: text/html
    Content-Language: da

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html lang="da">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>Debian GNU/Linux -- Det universelle styresystem</title>
    <link rev="made" href="mailto:webmaster@debian.org">
    <link rel="shortcut icon" href="favicon.ico">
    <meta name="Keywords" content="debian, GNU, linux, unix, open source, fri, free, DFSG">
    <meta name="Description" content="Debian GNU/Linux er en fri distribution af styresystemet GNU/Linux. Den vedligeholdes og opdateres af frivillige brugere, der donerer arbejde, tid og energi.">
    <meta name="Generator" content="WML 2.0.8 (30-Oct-2001)">
    <meta name="Modified" content="2003-03-03 23:32:50">
    </head>
    ...

  5. Ecrire une requête HTTP/1.1 sans connexion persistante:
    Pourquoi cela est-il utile?
    Réponse dans la rfc2616: A significant difference between HTTP/1.1 and earlier versions of HTTP is that persistent connections are the default behavior of any HTTP connection. That is, unless otherwise indicated, the client SHOULD assume that the server will maintain a persistent connection, even after error responses from the server. [...] An HTTP/1.1 server MAY assume that a HTTP/1.1 client intends to maintain a persistent connection unless a Connection header including the connection-token “close” was sent in the request.

    HEAD /~lfallet/index.htm HTTP/1.1
    Host: asi.insa-rouen.fr
    Connection:close

    HTTP/1.1 200 OK
    Date: Sun, 09 Mar 2003 21:55:26 GMT
    Server: Apache/1.3.22 (Unix) (Red-Hat/Linux) PHP/4.1.2
    Last-Modified: Sat, 08 Mar 2003 00:19:45 GMT
    ETag: "c4392-342d-3e693721"
    Accept-Ranges: bytes
    Content-Length: 13357
    Connection: close
    Content-Type: text/html

  6. Ecrire et analyser les requêtes retournant les codes suivants : 404, 501

    404 Not Found
    The server has not found anything matching the Request-URI. No indication is given of whether the condition is temporary or permanent. The 410 (Gone) status code SHOULD be used if the server knows, through some internally configurable mechanism, that an old resource is permanently unavailable and has no forwarding address. This status code is commonly used when the server does not wish to reveal exactly why the request has been refused, or when no other response is applicable.

    GET /superman.php HTTP/1.1
    Host: www.debian.org

    HTTP/1.1 404 Not Found
    Date: Mon, 03 Mar 2003 23:23:44 GMT
    Server: Apache/1.3.26 (Unix) Debian GNU/Linux PHP/4.1.2
    Transfer-Encoding: chunked
    Content-Type: text/html; charset=iso-8859-1

    501 Not Implemented
    The server does not support the functionality required to fulfill the request. This is the appropriate response when the server does not recognize the request method and is not capable of supporting it for any resource.

    Connected to localhost.localdomain (127.0.0.1).
    Escape character is '^]'.
    ^]

    <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
    <HTML><HEAD>
    <TITLE>501 Method Not Implemented</TITLE>
    </HEAD><BODY>
    <H1>Method Not Implemented</H1>
    ^] to /index.shtml not supported.<P>
    Invalid method in request ^]<P>
    <HR>
    <ADDRESS>Apache-AdvancedExtranetServer/1.3.26 Server at 172.20.1.119 Port 80</ADDRESS>
    </BODY></HTML>
    Connection closed by foreign host.

    302 Found
    The requested resource resides temporarily under a different URI. Since the redirection might be altered on occasion, the client SHOULD continue to use the Request-URI for future requests. This response is only cacheable if indicated by a Cache-Control or Expires header field.

    GET / HTTP/1.1
    Host: www.google.com
    Accept-Language: da,ro

    HTTP/1.1 302 Found
    Content-Length: 151
    Server: GWS/2.0
    Content-Type: text/html
    Date: Mon, 03 Mar 2003 23:26:31 GMT
    Location: http://www.google.fr/
    Set-Cookie: PREF=ID=0d06081051448380:TM=1046733991:LM=1046733991:S=EDPcLkqhoIHbtgXm; expires=Sun, 17-Jan-2038 19:14:07 GMT; path=/; domain=.google.com

    <HTML><HEAD><TITLE>302 Moved</TITLE></HEAD><BODY>
    <H1>302 Moved</H1>
    The document has moved
    <A HREF="http://www.google.fr/">here</A>.
    </BODY></HTML>

Valid XHTML 1.0!Retour à la liste de TP