Contenu connexe
Similaire à 第9回rest勉強会 ダウンロード・アップロード編 (20)
第9回rest勉強会 ダウンロード・アップロード編
- 6. HTTPレスポンス
HTTP/1.1 200 OK
Server: nginx
Date: Thu, 24 Sep 2015 09:11:53 GMT
Content-Type: text/html; charset=UTF-8
Transfer-Encoding: chunked
〜略〜
/openid20/www.yahoo.co.jp/xrds
Vary: Accept-Encoding
X-Frame-Options: SAMEORIGIN
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html;
charset=utf-8">
〜以下略〜
ステータスコード
レスポンスヘッダ
レスポンスボディ
空行
- 7. ステータスコード
HTTP/1.1 200 OK
Server: nginx
Date: Thu, 24 Sep 2015 09:11:53 GMT
Content-Type: text/html; charset=UTF-8
Transfer-Encoding: chunked
〜略〜
/openid20/www.yahoo.co.jp/xrds
Vary: Accept-Encoding
X-Frame-Options: SAMEORIGIN
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html;
charset=utf-8">
〜以下略〜
レスポンスヘッダ
レスポンスボディ
空行
- 8. ステータスコード
HTTP/1.1 200 OK
Server: nginx
Date: Thu, 24 Sep 2015 09:11:53 GMT
Content-Type: text/html; charset=UTF-8
Transfer-Encoding: chunked
〜略〜
/openid20/www.yahoo.co.jp/xrds
Vary: Accept-Encoding
X-Frame-Options: SAMEORIGIN
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html;
charset=utf-8">
〜以下略〜
レスポンスヘッダ
レスポンスボディ
空行HTTP1.1で通信しました。
ステータスコードは200, 正常です
- 9. レスポンスヘッダ
HTTP/1.1 200 OK
Server: nginx
Date: Thu, 24 Sep 2015 09:11:53 GMT
Content-Type: text/html; charset=UTF-8
Transfer-Encoding: chunked
〜略〜
/openid20/www.yahoo.co.jp/xrds
Vary: Accept-Encoding
X-Frame-Options: SAMEORIGIN
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html;
charset=utf-8">
〜以下略〜
レスポンスボディ
空行
- 10. レスポンスヘッダ
HTTP/1.1 200 OK
Server: nginx
Date: Thu, 24 Sep 2015 09:11:53 GMT
Content-Type: text/html; charset=UTF-8
Transfer-Encoding: chunked
〜略〜
/openid20/www.yahoo.co.jp/xrds
Vary: Accept-Encoding
X-Frame-Options: SAMEORIGIN
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html;
charset=utf-8">
〜以下略〜
レスポンスボディ
空行
レスポンスに関する付加情報
e.g) Content-Type: text/html; charset=UTF-8
レスポンスボディはhtmlですよ、エンコードはUTF-8ですよ!
- 11. 空行
HTTP/1.1 200 OK
Server: nginx
Date: Thu, 24 Sep 2015 09:11:53 GMT
Content-Type: text/html; charset=UTF-8
Transfer-Encoding: chunked
〜略〜
/openid20/www.yahoo.co.jp/xrds
Vary: Accept-Encoding
X-Frame-Options: SAMEORIGIN
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html;
charset=utf-8">
〜以下略〜
レスポンスボディ
- 12. 空行
HTTP/1.1 200 OK
Server: nginx
Date: Thu, 24 Sep 2015 09:11:53 GMT
Content-Type: text/html; charset=UTF-8
Transfer-Encoding: chunked
〜略〜
/openid20/www.yahoo.co.jp/xrds
Vary: Accept-Encoding
X-Frame-Options: SAMEORIGIN
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html;
charset=utf-8">
〜以下略〜
レスポンスボディ
これより下がレスポンスボディです!
- 13. レスポンスボディ
HTTP/1.1 200 OK
Server: nginx
Date: Thu, 24 Sep 2015 09:11:53 GMT
Content-Type: text/html; charset=UTF-8
Transfer-Encoding: chunked
〜略〜
/openid20/www.yahoo.co.jp/xrds
Vary: Accept-Encoding
X-Frame-Options: SAMEORIGIN
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html;
charset=utf-8">
〜以下略〜
ご所望のデータです!
- 14. レスポンスボディ
HTTP/1.1 200 OK
Server: nginx
Date: Thu, 24 Sep 2015 09:11:53 GMT
Content-Type: text/html; charset=UTF-8
Transfer-Encoding: chunked
〜略〜
/openid20/www.yahoo.co.jp/xrds
Vary: Accept-Encoding
X-Frame-Options: SAMEORIGIN
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html;
charset=utf-8">
〜以下略〜
ファイルをダウンロードする時も、
ファイルコンテンツはここに入って
くる
- 16. レスポンスヘッダを見よう!
HTTP/1.1 200 OK
Server: nginx
Date: Thu, 24 Sep 2015 09:11:53 GMT
Content-Type: text/html; charset=UTF-8
Transfer-Encoding: chunked
〜略〜
/openid20/www.yahoo.co.jp/xrds
Vary: Accept-Encoding
X-Frame-Options: SAMEORIGIN
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html;
charset=utf-8">
〜以下略〜
レスポンスボディ
空行
- 17. レスポンスヘッダを見よう!
HTTP/1.1 200 OK
Server: nginx
Date: Thu, 24 Sep 2015 09:11:53 GMT
Content-Type: text/html; charset=UTF-8
Transfer-Encoding: chunked
〜略〜
/openid20/www.yahoo.co.jp/xrds
Vary: Accept-Encoding
X-Frame-Options: SAMEORIGIN
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html;
charset=utf-8">
〜以下略〜
レスポンスボディ
空行
ブラウザ:
「Content-Type: text/html
とあるから表示だな!」
- 18. レスポンスヘッダを見よう!
HTTP/1.1 200 OK
Server: nginx
Date: Thu, 24 Sep 2015 09:11:53 GMT
Content-Type: text/csv; charset=UTF-8
Transfer-Encoding: chunked
〜略〜
/openid20/www.yahoo.co.jp/xrds
Vary: Accept-Encoding
X-Frame-Options: SAMEORIGIN
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html;
charset=utf-8">
〜以下略〜
レスポンスボディ
空行
- 19. レスポンスヘッダを見よう!
HTTP/1.1 200 OK
Server: nginx
Date: Thu, 24 Sep 2015 09:11:53 GMT
Content-Type: text/csv; charset=UTF-8
Transfer-Encoding: chunked
〜略〜
/openid20/www.yahoo.co.jp/xrds
Vary: Accept-Encoding
X-Frame-Options: SAMEORIGIN
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html;
charset=utf-8">
〜以下略〜
レスポンスボディ
空行
ブラウザ:
「Content-Type: text/csv
は保存だな!」
- 20. ブラウザによっては…
HTTP/1.1 200 OK
Server: nginx
Date: Thu, 24 Sep 2015 09:11:53 GMT
Content-Type: text/csv; charset=UTF-8
Transfer-Encoding: chunked
〜略〜
/openid20/www.yahoo.co.jp/xrds
Vary: Accept-Encoding
X-Frame-Options: SAMEORIGIN
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html;
charset=utf-8">
〜以下略〜
レスポンスボディ
空行
ブラウザX:
「Content-Type: text/csv
は表示だな!」
- 21. レスポンスヘッダを見よう!
HTTP/1.1 200 OK
Server: nginx
Date: Thu, 24 Sep 2015 09:11:53 GMT
Content-Type: text/csv; charset=UTF-8
Content-Disposition: attachment; filename="todo.csv"
Transfer-Encoding: chunked
〜略〜
/openid20/www.yahoo.co.jp/xrds
Vary: Accept-Encoding
X-Frame-Options: SAMEORIGIN
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
〜以下略〜
レスポンスボディ
空行
ブラウザ:
「Content-Disposition: attachment;
filename= todo.csv だか
ら、 todo.csv で保存だな!」
- 25. HTTPリクエスト
POST /rest-study/todo_lists/upload.json HTTP/1.1
Host: 10.0.1.206
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:42.0) Gecko/20100101 Firefox/42.0
〜略〜
Content-Length: 779
Content-Type: multipart/form-data; boundary=---------------------------1395431092341454357747073315
〜略〜
Cache-Control: no-cache
-----------------------------1395431092341454357747073315
Content-Disposition: form-data; name="0"; filename="todolist1.txt"
Content-Type: text/plain
todolist1.txtからアップロードしたTODO1
〜略〜
todolist1.txtからアップロードしたTODO5
-----------------------------1395431092341454357747073315
Content-Disposition: form-data; name="1"; filename="todolist2.txt"
Content-Type: text/plain
todolist2.txtからアップロードしたTODO1
todolist2.txtからアップロードしたTODO2
-----------------------------1395431092341454357747073315--
メソッド、URI
リクエストヘッダ
リクエストボディ
空行
- 26. メソッド、URI
POST /rest-study/todo_lists/upload.json HTTP/1.1
Host: 10.0.1.206
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:42.0) Gecko/20100101 Firefox/42.0
〜略〜
Content-Length: 779
Content-Type: multipart/form-data; boundary=---------------------------1395431092341454357747073315
〜略〜
Cache-Control: no-cache
-----------------------------1395431092341454357747073315
Content-Disposition: form-data; name="0"; filename="todolist1.txt"
Content-Type: text/plain
todolist1.txtからアップロードしたTODO1
〜略〜
todolist1.txtからアップロードしたTODO5
-----------------------------1395431092341454357747073315
Content-Disposition: form-data; name="1"; filename="todolist2.txt"
Content-Type: text/plain
todolist2.txtからアップロードしたTODO1
todolist2.txtからアップロードしたTODO2
-----------------------------1395431092341454357747073315--
リクエストヘッダ
リクエストボディ
空行
- 27. メソッド、URI
POST /rest-study/todo_lists/upload.json HTTP/1.1
Host: 10.0.1.206
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:42.0) Gecko/20100101 Firefox/42.0
〜略〜
Content-Length: 779
Content-Type: multipart/form-data; boundary=---------------------------1395431092341454357747073315
〜略〜
Cache-Control: no-cache
-----------------------------1395431092341454357747073315
Content-Disposition: form-data; name="0"; filename="todolist1.txt"
Content-Type: text/plain
todolist1.txtからアップロードしたTODO1
〜略〜
todolist1.txtからアップロードしたTODO5
-----------------------------1395431092341454357747073315
Content-Disposition: form-data; name="1"; filename="todolist2.txt"
Content-Type: text/plain
todolist2.txtからアップロードしたTODO1
todolist2.txtからアップロードしたTODO2
-----------------------------1395431092341454357747073315--
リクエストヘッダ
リクエストボディ
空行メソッドは「POST」、
URL「/rest-study/todo_lists/
upload.json」にHTTP1.1で通信
します。
- 28. リクエストヘッダ
POST /rest-study/todo_lists/upload.json HTTP/1.1
Host: 10.0.1.206
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:42.0) Gecko/20100101 Firefox/42.0
〜略〜
Content-Length: 779
Content-Type: multipart/form-data;
boundary=---------------------------1395431092341454357747073315
〜略〜
Cache-Control: no-cache
-----------------------------1395431092341454357747073315
Content-Disposition: form-data; name="0"; filename="todolist1.txt"
Content-Type: text/plain
todolist1.txtからアップロードしたTODO1
〜略〜
todolist1.txtからアップロードしたTODO5
-----------------------------1395431092341454357747073315
Content-Disposition: form-data; name="1"; filename="todolist2.txt"
Content-Type: text/plain
todolist2.txtからアップロードしたTODO1
todolist2.txtからアップロードしたTODO2
-----------------------------1395431092341454357747073315--
リクエストボディ
空行
- 29. リクエストヘッダ
POST /rest-study/todo_lists/upload.json HTTP/1.1
Host: 10.0.1.206
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:42.0) Gecko/20100101 Firefox/42.0
〜略〜
Content-Length: 779
Content-Type: multipart/form-data;
boundary=---------------------------1395431092341454357747073315
〜略〜
Cache-Control: no-cache
-----------------------------1395431092341454357747073315
Content-Disposition: form-data; name="0"; filename="todolist1.txt"
Content-Type: text/plain
todolist1.txtからアップロードしたTODO1
〜略〜
todolist1.txtからアップロードしたTODO5
-----------------------------1395431092341454357747073315
Content-Disposition: form-data; name="1"; filename="todolist2.txt"
Content-Type: text/plain
todolist2.txtからアップロードしたTODO1
todolist2.txtからアップロードしたTODO2
-----------------------------1395431092341454357747073315--
リクエストボディ
空行
リクエストに関する付加情報
e.g) Content-Length: 779 リクエストボディのサイ
ズは779バイトですよ!
- 30. 空行
POST /rest-study/todo_lists/upload.json HTTP/1.1
Host: 10.0.1.206
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:42.0) Gecko/20100101 Firefox/42.0
〜略〜
Content-Length: 779
Content-Type: multipart/form-data;
boundary=---------------------------1395431092341454357747073315
〜略〜
Cache-Control: no-cache
-----------------------------1395431092341454357747073315
Content-Disposition: form-data; name="0"; filename="todolist1.txt"
Content-Type: text/plain
todolist1.txtからアップロードしたTODO1
〜略〜
todolist1.txtからアップロードしたTODO5
-----------------------------1395431092341454357747073315
Content-Disposition: form-data; name="1"; filename="todolist2.txt"
Content-Type: text/plain
todolist2.txtからアップロードしたTODO1
todolist2.txtからアップロードしたTODO2
-----------------------------1395431092341454357747073315--
リクエストボディ
- 31. 空行
POST /rest-study/todo_lists/upload.json HTTP/1.1
Host: 10.0.1.206
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:42.0) Gecko/20100101 Firefox/42.0
〜略〜
Content-Length: 779
Content-Type: multipart/form-data;
boundary=---------------------------1395431092341454357747073315
〜略〜
Cache-Control: no-cache
-----------------------------1395431092341454357747073315
Content-Disposition: form-data; name="0"; filename="todolist1.txt"
Content-Type: text/plain
todolist1.txtからアップロードしたTODO1
〜略〜
todolist1.txtからアップロードしたTODO5
-----------------------------1395431092341454357747073315
Content-Disposition: form-data; name="1"; filename="todolist2.txt"
Content-Type: text/plain
todolist2.txtからアップロードしたTODO1
todolist2.txtからアップロードしたTODO2
-----------------------------1395431092341454357747073315--
リクエストボディ
これより下がリクエストボディです!
- 32. リクエストボディ
POST /rest-study/todo_lists/upload.json HTTP/1.1
Host: 10.0.1.206
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:42.0) Gecko/20100101 Firefox/42.0
〜略〜
Content-Length: 779
Content-Type: multipart/form-data;
boundary=---------------------------1395431092341454357747073315
〜略〜
Cache-Control: no-cache
-----------------------------1395431092341454357747073315
Content-Disposition: form-data; name="0"; filename="todolist1.txt"
Content-Type: text/plain
todolist1.txtからアップロードしたTODO1
〜略〜
todolist1.txtからアップロードしたTODO5
-----------------------------1395431092341454357747073315
Content-Disposition: form-data; name="1"; filename="todolist2.txt"
Content-Type: text/plain
todolist2.txtからアップロードしたTODO1
todolist2.txtからアップロードしたTODO2
-----------------------------1395431092341454357747073315--
- 33. リクエストボディ
POST /rest-study/todo_lists/upload.json HTTP/1.1
Host: 10.0.1.206
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:42.0) Gecko/20100101 Firefox/42.0
〜略〜
Content-Length: 779
Content-Type: multipart/form-data;
boundary=---------------------------1395431092341454357747073315
〜略〜
Cache-Control: no-cache
-----------------------------1395431092341454357747073315
Content-Disposition: form-data; name="0"; filename="todolist1.txt"
Content-Type: text/plain
todolist1.txtからアップロードしたTODO1
〜略〜
todolist1.txtからアップロードしたTODO5
-----------------------------1395431092341454357747073315
Content-Disposition: form-data; name="1"; filename="todolist2.txt"
Content-Type: text/plain
todolist2.txtからアップロードしたTODO1
todolist2.txtからアップロードしたTODO2
-----------------------------1395431092341454357747073315--
これを送ります!
- 34. multipart/form-data
POST /rest-study/todo_lists/upload.json HTTP/1.1
Host: 10.0.1.206
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:42.0) Gecko/20100101 Firefox/42.0
〜略〜
Content-Length: 779
Content-Type: multipart/form-data;
boundary=---------------------------1395431092341454357747073315
〜略〜
Cache-Control: no-cache
-----------------------------1395431092341454357747073315
Content-Disposition: form-data; name="0"; filename="todolist1.txt"
Content-Type: text/plain
todolist1.txtからアップロードしたTODO1
〜略〜
todolist1.txtからアップロードしたTODO5
-----------------------------1395431092341454357747073315
Content-Disposition: form-data; name="1"; filename="todolist2.txt"
Content-Type: text/plain
todolist2.txtからアップロードしたTODO1
todolist2.txtからアップロードしたTODO2
-----------------------------1395431092341454357747073315--
ボディの中にまたヘッダとボディが?
- 35. multipart/form-data
POST /rest-study/todo_lists/upload.json HTTP/1.1
Host: 10.0.1.206
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:42.0) Gecko/20100101 Firefox/42.0
〜略〜
Content-Length: 779
Content-Type: multipart/form-data;
boundary=---------------------------1395431092341454357747073315
〜略〜
Cache-Control: no-cache
-----------------------------1395431092341454357747073315
Content-Disposition: form-data; name="0"; filename="todolist1.txt"
Content-Type: text/plain
todolist1.txtからアップロードしたTODO1
〜略〜
todolist1.txtからアップロードしたTODO5
-----------------------------1395431092341454357747073315
Content-Disposition: form-data; name="1"; filename="todolist2.txt"
Content-Type: text/plain
todolist2.txtからアップロードしたTODO1
todolist2.txtからアップロードしたTODO2
-----------------------------1395431092341454357747073315--
todolist1.txtの情報
- 36. multipart/form-data
POST /rest-study/todo_lists/upload.json HTTP/1.1
Host: 10.0.1.206
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:42.0) Gecko/20100101 Firefox/42.0
〜略〜
Content-Length: 779
Content-Type: multipart/form-data;
boundary=---------------------------1395431092341454357747073315
〜略〜
Cache-Control: no-cache
-----------------------------1395431092341454357747073315
Content-Disposition: form-data; name="0"; filename="todolist1.txt"
Content-Type: text/plain
todolist1.txtからアップロードしたTODO1
〜略〜
todolist1.txtからアップロードしたTODO5
-----------------------------1395431092341454357747073315
Content-Disposition: form-data; name="1"; filename="todolist2.txt"
Content-Type: text/plain
todolist2.txtからアップロードしたTODO1
todolist2.txtからアップロードしたTODO2
-----------------------------1395431092341454357747073315--
todolist1.txtの情報
todolist2.txtの情報