##Задание 1.3
###Отправить запросы на http://httpbin.org, проанализировать ответ и код состояния. Описать работу HTTP протокола в каждом запросе.
telnet http://httpbin.org 80
Trying 54.175.219.8...
Connected to httpbin.org.
Escape character is '^]'.
Подключился к http://httpbin.org по 80 порту
GET /ip HTTP/1.1
Host: httpbin.org
Accept: */*
HTTP/1.1 200 OK
Server: nginx
Date: Fri, 09 Sep 2016 12:01:30 GMT
Content-Type: application/json
Content-Length: 32
Connection: keep-alive
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true
{
"origin": "212.193.76.52"
}
Отправил Get запрос по адресу /ip. Получил код 200, который означает, что запрос выполнен успешно. В теле получил ip
GET /get?foo=bar&1=2&2/0&error=True HTTP/1.1
Host: httpbin.org
Accept: */*
HTTP/1.1 200 OK
Server: nginx
Date: Fri, 09 Sep 2016 12:12:24 GMT
Content-Type: application/json
Content-Length: 254
Connection: keep-alive
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true
{
"args": {
"1": "2",
"2/0": "",
"error": "True",
"foo": "bar"
},
"headers": {
"Accept": "*/*",
"Host": "httpbin.org"
},
"origin": "212.193.76.52",
"url": "http://httpbin.org/get?foo=bar&1=2&2%2F0&error=True"
}
Выполнил Get запрос с передачей параметров. Получил код 200 - успешно. В теле вернулись в формате json значения переменных, их заголовки и url
POST /post HTTP/1.1
Host: httpbin.org
Accept: */*
Content-Length: 35
Content-Type: application/x-www-form-urlencoded
foo=bar&1=2&2%2F0=&error=True
HTTP/1.1 200 OK
Server: nginx
Date: Fri, 09 Sep 2016 12:09:02 GMT
Content-Type: application/json
Content-Length: 388
Connection: keep-alive
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true
{
"args": {},
"data": "",
"files": {},
"form": {
"1": "2",
"2/0": "",
"error": "True\r\n\r\n\r\n",
"foo": "bar"
},
"headers": {
"Accept": "*/*",
"Content-Length": "35",
"Content-Type": "application/x-www-form-urlencoded",
"Host": "httpbin.org"
},
"json": null,
"origin": "212.193.76.52",
"url": "http://httpbin.org/post"
}
Отправил post запрос с переменными. В ответ получил код 200 - успешно. В теле получил переменные, заголовки, ip клиента и url на который был отправлен запрос
GET /cookies/set?country=Ru HTTP/1.1
Host: httpbin.org
Accept: */*
HTTP/1.1 302 FOUND
Server: nginx
Date: Fri, 09 Sep 2016 12:20:13 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 223
Connection: keep-alive
Location: /cookies
Set-Cookie: country=Ru; Path=/
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<title>Redirecting...</title>
<h1>Redirecting...</h1>
<p>You should be redirected automatically to target URL: <a href="/cookies">/cookies</a>. If not click the link.
Отправил Get запрос на ресурс /cookies/set с указанием параметра Country и заголовков запроса. В ответ получил код 302, который означает что документ был найден, но в данный момент временно находится по другому адресу. Адрес можно увидеть в заголовке 'Location'
GET /cookies HTTP/1.1
Host: httpbin.org
Accept: */*
HTTP/1.1 200 OK
Server: nginx
Date: Fri, 09 Sep 2016 12:25:38 GMT
Content-Type: application/json
Content-Length: 20
Connection: keep-alive
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true
{
"cookies": {}
}
Отправил get запрос по адресу /cookies. В ответ получил код 200. В теле получил параменр cookeis с пустым значением
GET /redirect/4 HTTP/1.1
Host: httpbin.org
Accept: */*
HTTP/1.1 302 FOUND
Server: nginx
Date: Fri, 09 Sep 2016 12:28:16 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 247
Connection: keep-alive
Location: /relative-redirect/3
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<title>Redirecting...</title>
<h1>Redirecting...</h1>
<p>You should be redirected automatically to target URL: <a href="/relative-redirect/3">/relative-redirect/3</a>. If not click the link.
Выполнил запрос по адресу /redirect/4. В ответ был получен код 302 - документ временно доступен по другому адресу, который указан в заголовке 'Location'