Skip to content

Instantly share code, notes, and snippets.

@sashachabin
Last active August 3, 2021 12:58
Show Gist options
  • Save sashachabin/5296a060beb97e0429d07c0dfb008dfd to your computer and use it in GitHub Desktop.
Save sashachabin/5296a060beb97e0429d07c0dfb008dfd to your computer and use it in GitHub Desktop.
УрФУ. Отправить запросы на http://httpbin.org, проанализировать ответ и код состояния. Описать работу HTTP протокола в каждом запросе.
Запрос № 1:
$ telnet httpbin.org 80
Trying 54.243.67.94...
Connected to httpbin.org.
Escape character is '^]'.
GET /ip HTTP/1.1
Host: httpbin.org
Accept: */*
Ответ № 1:
HTTP/1.1 200 OK
Connection: keep-alive
Server: meinheld/0.6.1
Date: Sat, 23 Sep 2017 09:36:49 GMT
Content-Type: application/json
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true
X-Powered-By: Flask
X-Processed-Time: 0.000447034835815
Content-Length: 33
Via: 1.1 vegur
{
"origin": "87.224.209.39"
}
Сервер вернул статус 200, т.е. запрос выполнен успешно.
В формате JSON выведен IP-адрес клиента.
------------------------------------------
Запрос № 2:
$ telnet httpbin.org 80
Trying 54.225.177.165...
Connected to httpbin.org.
Escape character is '^]'.
GET /get?foo=bar&1=2&2/0&error=True HTTP/1.1
Host: httpbin.org
Accept: */*
Ответ № 2:
HTTP/1.1 200 OK
Connection: keep-alive
Server: meinheld/0.6.1
Date: Sat, 23 Sep 2017 09:40:58 GMT
Content-Type: application/json
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true
X-Powered-By: Flask
X-Processed-Time: 0.00104308128357
Content-Length: 283
Via: 1.1 vegur
{
"args": {
"1": "2",
"2/0": "",
"error": "True",
"foo": "bar"
},
"headers": {
"Accept": "*/*",
"Connection": "close",
"Host": "httpbin.org"
},
"origin": "87.224.209.39",
"url": "http://httpbin.org/get?foo=bar&1=2&2%2F0&error=True"
}
Был отправлен GET-запрос, на который сервер вернул статус 200, т.е. запрос выполнен успешно.
В формате JSON вывден IP-адрес клиента и URL, по которому клиент обращался.
------------------------------------------
Запрос № 3:
$ telnet httpbin.org 80
Trying 23.21.184.78...
Connected to httpbin.org.
Escape character is '^]'.
POST /post HTTP/1.1
Host: httpbin.org
Accept: */*
Content-Length: 29
Content-Type: application/x-www-form-urlencoded
foo=bar&1=2&2%2F0=&error=True
HTTP/1.1 200 OK
Connection: keep-alive
Server: meinheld/0.6.1
Date: Sat, 23 Sep 2017 09:45:34 GMT
Content-Type: application/json
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true
X-Powered-By: Flask
X-Processed-Time: 0.000836133956909
Content-Length: 405
Via: 1.1 vegur
{
"args": {},
"data": "",
"files": {},
"form": {
"1": "2",
"2/0": "",
"error": "True",
"foo": "bar"
},
"headers": {
"Accept": "*/*",
"Connection": "close",
"Content-Length": "29",
"Content-Type": "application/x-www-form-urlencoded",
"Host": "httpbin.org"
},
"json": null,
"origin": "87.224.209.39",
"url": "http://httpbin.org/post"
}
Был отправлен POST-запрос, на который сервер вернул статус 200, т.е. запрос выполнен успешно.
В формате JSON вывден IP-адрес клиента и URL, по которому клиент обращался.
------------------------------------------
Запрос № 4:
$ telnet httpbin.org 80
GET /cookies/set?country=Ru HTTP/1.1
Host: httpbin.org
Accept: */* Trying 23.21.140.122...
Connected to httpbin.org.
Escape character is '^]'.
Ответ № 4:
HTTP/1.1 302 FOUND
Connection: keep-alive
Server: meinheld/0.6.1
Date: Sat, 23 Sep 2017 09:47:45 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 223
Location: /cookies
Set-Cookie: country=Ru; Path=/
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true
X-Powered-By: Flask
X-Processed-Time: 0.000689029693604
Via: 1.1 vegur
<!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.
Был отправлен запрос на изменение cookies. Сервер вернул статус 302, который обозначает, что запрошенный документ временно доступен по другому URI, указанному в заголовке в поле Location (/cookies)
------------------------------------------
Запрос № 5:
$ telnet httpbin.org 80
GET /cookies HTTP/1.1
Host: httpbin.org
Accept: */* Trying 54.243.161.178...
Connected to httpbin.org.
Escape character is '^]'.
Ответ № 5:
HTTP/1.1 200 OK
Connection: keep-alive
Server: meinheld/0.6.1
Date: Sat, 23 Sep 2017 09:48:58 GMT
Content-Type: application/json
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true
X-Powered-By: Flask
X-Processed-Time: 0.000458955764771
Content-Length: 20
Via: 1.1 vegur
{
"cookies": {}
}
Сервер вернул статус 200, т.е. запрос выполнен успешно.
В JSON-формате сервер показал, что cookies клиента пустые.
------------------------------------------
Запрос № 6:
$ telnet httpbin.org 80
Trying 54.243.67.94...
Connected to httpbin.org.
Escape character is '^]'.
GET /redirect/4 HTTP/1.1
Host: httpbin.org
Accept: */*
Ответ № 6:
HTTP/1.1 302 FOUND
Connection: keep-alive
Server: meinheld/0.6.1
Date: Sat, 23 Sep 2017 09:50:04 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 247
Location: /relative-redirect/3
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true
X-Powered-By: Flask
X-Processed-Time: 0.000678062438965
Via: 1.1 vegur
<!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.
Сервер вернул статус 302, который обозначает, что запрошенный документ временно доступен по другому URI, указанному в заголовке в поле Location (/relative-redirect/3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment