Руководство по HTTP. Примеры

Пример 1

HTTP запрос страницы tutorials.html от веб-сервера, на котором работает proselyte.net

Запрос


GET /tutrials.html HTTP/1.1
User-Agent: Mozilla/4.0 (compatible; MSIE5.01; Windows NT)
Host: www.proselyte.net
Accept-Language: en-us
Accept-Encoding: gzip, deflate
Connection: Keep-Alive

Ответ


HTTP/1.1 200 OK
Date: Fri, 27 May 2016 22:19:57 GMT
Server: Apache/2.2.14 (Win32)
Last-Modified: Wed, 25 May 2016 04:39:18 GMT
Content-Length: 88
Content-Type: text/html
Connection: Closed

<html>
   <body>
   <h1>Proselyte Tutorials</h1>
   </body>
</html>

Пример 2

Запрос несуществующей страницы nullpage.html с сервера, на котором работает proselyte.net

Запрос


GET /nullpage.html HTTP/1.1
User-Agent: Mozilla/4.0 (compatible; MSIE5.01; Windows NT)
Host: www.proselyte.net
Accept-Language: en-us
Accept-Encoding: gzip, deflate
Connection: Keep-Alive

Ответ


HTTP/1.1 404 Not Found
Date: Fri, 27 May 2016 22:19:57 GMT
Server: Apache/2.2.14 (Win32)
Content-Length: 230
Content-Type: text/html; charset=iso-8859-1
Connection: Closed

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html>

<head>
   <title>404 Not Found</title>
</head>

<body>
   <h1>Not Found</h1>
   <p>The requested URL /t.html was not found on this server.</p>
</body>

</html>

Пример 3
Запрос страницы tutorials.html с сервера, на котором работает proselyte.net, с запросом некорректной версии протокола HTTP:

Запрос


GET /tutorials.html HTTP1
User-Agent: Mozilla/4.0 (compatible; MSIE5.01; Windows NT)
Host: www.proselyte,net
Accept-Language: en-us
Accept-Encoding: gzip, deflate
Connection: Keep-Alive

Ответ


HTTP/1.1 400 Bad Request
Date: Fri, 27 May 2016 22:19:57 GMT
Server: Apache/2.2.14 (Win32)
Content-Length: 230
Content-Type: text/html; charset=iso-8859-1
Connection: Closed

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html>

<head>
   <title>400 Bad Request</title>
</head>

<body>
   <h1>Bad Request</h1>
   <p>Your browser sent a request that this server could not understand.<p>
   <p>The request line contained invalid characters following the protocol string.<p>
</body>

</html>

На этом мы заканчиваем изучение протокола HTTP.