...

• HTTPの規格 • HTTPメッセージの基本

by user

on
Category: Documents
6

views

Report

Comments

Transcript

• HTTPの規格 • HTTPメッセージの基本
第5回の内容
• HTTPの規格
• HTTPメッセージの基本
HTTPの規格
HTTPの規格
• Internet Engineering Task Force (IETF)
• Request for Comments (RFC)
年
バージョン
RFC
1996年
HTTP/1.0
RFC 1945
Hypertext Transfer Protocol -- HTTP/1.0
1997年
HTTP/1.1
RFC 2068
Hypertext Transfer Protocol -- HTTP/1.1
1999年
HTTP/1.1
(改訂版)
RFC 2616
Hypertext Transfer Protocol -- HTTP/1.1
RFC 2616の改訂
•
•
•
•
•
•
RFC 7230
Hypertext Transfer Protocol (HTTP/1.1): Message Syntax and
Routing
RFC 7231
Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content
RFC 7232
Hypertext Transfer Protocol (HTTP/1.1): Conditional Requests
RFC 7233
Hypertext Transfer Protocol (HTTP/1.1): Range Requests
RFC 7234
Hypertext Transfer Protocol (HTTP/1.1): Caching
RFC 7235
Hypertext Transfer Protocol (HTTP/1.1): Authentication
RFC
内容
RFC
URI
RFC 3986
Uniform Resource Identifier (URI): Generic Syntax
HTTP認証
RFC 2617
HTTP Authentication: Basic and Digest Access Authentication
RFC 7235
Hypertext Transfer Protocol (HTTP/1.1): Authentication
CGI
RFC 3875
The Common Gateway Interface (CGI) Version 1.1
クッキー
RFC 6265
HTTP State Management Mechanism
HTTPメッセージの基本
HTTPメッセージの構造
リクエストメッセージ
レスポンスメッセージ
リクエストライン
ステータスライン
メッセージヘッダ
メッセージヘッダ
空行
空行
メッセージボディ
メッセージボディ
メッセージヘッダ
フィールド名: フィールド値
Content-Type: text/html; charset=utf-8
フィールド名
フィールド値
リクエストメッセージの例
リクエストライン
メッセージヘッダ
空行
メッセージボディ
GET /test.html HTTP/1.1
Host: www.example.ac.jp
リクエストメッセージの例
リクエストライン
メッセージヘッダ
空行
メッセージボディ
GET /test.html HTTP/1.1
Host: www.example.ac.jp
リクエストメッセージの例
リクエストライン
メッセージヘッダ
空行
メッセージボディ
GET /test.html HTTP/1.1
Host: www.example.ac.jp
リクエストメッセージの例
リクエストライン
メッセージヘッダ
空行
メッセージボディ
GET /test.html HTTP/1.1
Host: www.example.ac.jp
リクエストメッセージの例
リクエストライン
メッセージヘッダ
空行
メッセージボディ
GET /test.html HTTP/1.1
Host: www.example.ac.jp
レスポンスメッセージの例
ステータスライン
メッセージヘッダ
空行
メッセージボディ
HTTP/1.1 200 OK
Date: Tue, 01 Oct 2013 09:17:32 GMT
Content-Length: 244
Content-Type: text/html; charset=utf-8
<!DOCTYPE html>
<html lang="ja">
(以下略)
レスポンスメッセージの例
ステータスライン
メッセージヘッダ
空行
メッセージボディ
HTTP/1.1 200 OK
Date: Tue, 01 Oct 2013 09:17:32 GMT
Content-Length: 244
Content-Type: text/html; charset=utf-8
<!DOCTYPE html>
<html lang="ja">
(以下略)
レスポンスメッセージの例
ステータスライン
メッセージヘッダ
空行
メッセージボディ
HTTP/1.1 200 OK
Date: Tue, 01 Oct 2013 09:17:32 GMT
Content-Length: 244
Content-Type: text/html; charset=utf-8
<!DOCTYPE html>
<html lang="ja">
(以下略)
レスポンスメッセージの例
ステータスライン
メッセージヘッダ
空行
メッセージボディ
HTTP/1.1 200 OK
Date: Tue, 01 Oct 2013 09:17:32 GMT
Content-Length: 244
Content-Type: text/html; charset=utf-8
<!DOCTYPE html>
<html lang="ja">
(以下略)
レスポンスメッセージの例
ステータスライン
メッセージヘッダ
空行
メッセージボディ
HTTP/1.1 200 OK
Date: Tue, 01 Oct 2013 09:17:32 GMT
Content-Length: 244
Content-Type: text/html; charset=utf-8
<!DOCTYPE html>
<html lang="ja">
(以下略)
リクエストライン
GET /test.html HTTP/1.1
Host: www.example.ac.jp
GET /test.html HTTP/1.1
HTTPメソッド
HTTPのバージョン
URIのパスとクエリ
Hostヘッダ
GET /test.html HTTP/1.1
Host: www.example.ac.jp
Host: www.example.ac.jp
ホスト名(:ポート番号)
http://www.example.ac.jp/test.html
名前ベースのバーチャルホスト
http://www.ouj.ac.jp/
www.ouj.ac.jp
 172.19.0.1
www.example.ac.jp
 192.168.18.3
test.example.ac.jp
 192.168.18.5
名前ベースのバーチャルホスト
http://www.example.ac.jp/
www.ouj.ac.jp
 172.19.0.1
www.example.ac.jp
 192.168.18.3
test.example.ac.jp
 192.168.18.5
名前ベースのバーチャルホスト
http://test.example.ac.jp/
www.ouj.ac.jp
 172.19.0.1
www.example.ac.jp
 192.168.18.3
test.example.ac.jp
 192.168.18.5
名前ベースのバーチャルホスト
http://www.ouj.ac.jp/
http://www.example.ac.jp/
http://test.example.ac.jp/
www.ouj.ac.jp
www.example.ac.jp
test.example.ac.jp
 172.19.0.1
Host: www.example.ac.jp
ステータスライン
HTTP/1.1 200 OK
Date: Tue, 01 Oct 2013 09:17:32 GMT
Content-Length: 244
Content-Type: text/html; charset=utf-8
<!DOCTYPE html>
<html lang="ja">
(以下略)
ステータスライン
HTTP/1.1 200 OK
Date: Tue, 01 Oct 2013 09:17:32 GMT
Content-Length: 244
Content-Type: text/html; charset=utf-8
<!DOCTYPE html>
HTTP/1.1 200
<html lang="ja">
(以下略)
HTTPのバージョン
OK
ステータスコードの説明
ステータスコード
ステータスコード
ステータ 説明
スコード
意味
200
OK
リクエストに成功した
404
Not Found
リソースが存在しない
403
Forbidden
権限がない
500
Internal Server Error
サーバ側でエラーが起こった
レスポンスメッセージのヘッダ
HTTP/1.1 200 OK
Date: Tue, 01 Oct 2013 09:17:32 GMT
Content-Length: 244
Content-Type: text/html; charset=utf-8
<!DOCTYPE html>
<html lang="ja">
(以下略)
レスポンスメッセージのヘッダ
HTTP/1.1 200 OK
Date: Tue, 01 Oct 2013 09:17:32 GMT
Content-Length: 244
Content-Type: text/html; charset=utf-8
<!DOCTYPE html>
ヘッダ
意味
<html lang="ja">
Date (以下略)
メッセージが作成された日時
レスポンスメッセージのヘッダ
HTTP/1.1 200 OK
Date: Tue, 01 Oct 2013 09:17:32 GMT
Content-Length: 244
Content-Type: text/html; charset=utf-8
<!DOCTYPE html>
ヘッダ
意味
<html lang="ja">
Date (以下略)
メッセージが作成された日時
Content-Length 送り返すリソースのサイズ (バイト)
レスポンスメッセージのヘッダ
HTTP/1.1 200 OK
Date: Tue, 01 Oct 2013 09:17:32 GMT
Content-Length: 244
Content-Type: text/html; charset=utf-8
<!DOCTYPE html>
ヘッダ
意味
<html lang="ja">
Date (以下略)
メッセージが作成された日時
Content-Length 送り返すリソースのサイズ (バイト)
Content-Type
送り返すリソースのメディアタイプ
レスポンスメッセージのヘッダ
HTTP/1.1 200 OK
Date: Tue, 01 Oct 2013 09:17:32 GMT
Content-Length: 244
Content-Type: text/html; charset=utf-8
<!DOCTYPE html>
<html lang="ja">
(以下略)
HTTPメッセージの実例
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" href="./style.css" type="text/css">
<title>放送太郎の自己紹介</title>
</head>
<body>
<h1>放送太郎の自己紹介</h1>
<h2>略歴</h2>
<p>
神奈川県横浜市出身。1983年生まれの29歳です。大学では英文学を学びました。
現在は、千葉県の<a href="http://www.ouj.ac.jp/">放送大学</a>本部で勤務しています。
<img src="./ouj.jpg" alt="放送大学本部を正門側から撮った写真。右の建物の屋上に電波塔が見える。">
</p>
<h2>趣味</h2>
<ul>
<li>読書</li>
<li>オートバイ</li>
<li>プラモデル製作</li>
</ul>
<address>連絡先: <a href="mailto:[email protected]">[email protected]</a></address>
</body>
</html>
HTTPメッセージの実例
http://www.example.ac.jp/taro.html
HTTPメッセージの実例
1回目のHTTPリクエスト・レスポンス
GET /taro.html HTTP/1.1
Host: www.example.ac.jp
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:30.0) Gecko/20100101 Firefox/30.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: ja,en-us;q=0.7,en;q=0.3
Accept-Encoding: gzip, deflate
リクエスト
Connection: keep-alive
HTTP/1.1 200 OK
Date: Thu, 12 Jun 2014 10:26:23 GMT
Server: Apache
Last-Modified: Thu, 12 Jun 2014 01:58:09 GMT
Etag: "37c-4fb99e47fee40"
Accept-Ranges: bytes
Content-Length: 892
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: text/html; charset=utf-8
レスポンス
取得したHTML文書
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" href="./style.css" type="text/css">
<title>放送太郎の自己紹介</title>
</head>
<body>
<h1>放送太郎の自己紹介</h1>
<h2>略歴</h2>
<p>
神奈川県横浜市出身。1983年生まれの29歳です。大学では英文学を学びました。
現在は、千葉県の<a href="http://www.ouj.ac.jp/">放送大学</a>本部で勤務しています。
<img src="./ouj.jpg" alt="放送大学本部を正門側から撮った写真。右の建物の屋上に電波塔が見える。">
</p>
<h2>趣味</h2>
<ul>
<li>読書</li>
<li>オートバイ</li>
<li>プラモデル製作</li>
</ul>
<address>連絡先: <a href="mailto:[email protected]">[email protected]</a></address>
</body>
</html>
2回目のHTTPリクエスト・レスポンス
GET /style.css HTTP/1.1
Host: www.example.ac.jp
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:30.0) Gecko/20100101 Firefox/30.0
Accept: text/css,*/*;q=0.1
Accept-Language: ja,en-us;q=0.7,en;q=0.3
Accept-Encoding: gzip, deflate
リクエスト
Connection: keep-alive
HTTP/1.1 200 OK
Date: Thu, 12 Jun 2014 10:26:23 GMT
Server: Apache
Last-Modified: Mon, 02 Jun 2014 07:37:14 GMT
Etag: "86-4fad576be3e80"
Accept-Ranges: bytes
Content-Length: 134
Keep-Alive: timeout=5, max=99
Connection: Keep-Alive
Content-Type: text/css
レスポンス
3回目のHTTPリクエスト・レスポンス
GET /ouj.jpg HTTP/1.1
Host: www.example.ac.jp
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:30.0) Gecko/20100101 Firefox/30.0
Accept: image/png,image/*;q=0.8,*/*;q=0.5
Accept-Language: ja,en-us;q=0.7,en;q=0.3
Accept-Encoding: gzip, deflate
リクエスト
Connection: keep-alive
HTTP/1.1 200 OK
Date: Thu, 12 Jun 2014 10:26:23 GMT
Server: Apache
Last-Modified: Tue, 10 Jun 2014 02:08:27 GMT
Etag: "9fca-4fb71cda71cc0"
Accept-Ranges: bytes
Content-Length: 40906
Keep-Alive: timeout=5, max=98
Connection: Keep-Alive
Content-Type: image/jpeg
レスポンス
1回目のHTTPリクエスト・レスポンス
GET /taro.html HTTP/1.1
Host: www.example.ac.jp
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:30.0) Gecko/20100101 Firefox/30.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
③ HTTPメソッド
Accept-Language: ja,en-us;q=0.7,en;q=0.3
Accept-Encoding: gzip, deflate
リクエスト
Connection: keep-alive
① 持続的接続
HTTP/1.1 200 OK
Date: Thu, 12 Jun 2014 10:26:23 GMT
Server: Apache
Last-Modified: Thu, 12 Jun 2014 01:58:09 GMT
④ ステータスコード
Etag: "37c-4fb99e47fee40"
Accept-Ranges: bytes
② メッセージボディのサイズ
Content-Length: 892
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
① 持続的接続
Content-Type: text/html; charset=utf-8
レスポンス
持続的接続
クライアント
持
続
的
接
続
な
し
サーバ
クライアント
サーバ
持
続
的
接
続
あ
り
⋮
1回目のHTTPリクエスト・レスポンス
GET /taro.html HTTP/1.1
Host: www.example.ac.jp
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:30.0) Gecko/20100101 Firefox/30.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: ja,en-us;q=0.7,en;q=0.3
Accept-Encoding: gzip, deflate
リクエスト
Connection: keep-alive
HTTP/1.1 200 OK
Date: Thu, 12 Jun 2014 10:26:23 GMT
Server: Apache
Last-Modified: Thu, 12 Jun 2014 01:58:09 GMT
Etag: "37c-4fb99e47fee40"
Accept-Ranges: bytes
Content-Length: 892
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: text/html; charset=utf-8
レスポンス
1回目のHTTPリクエスト・レスポンス
GET /taro.html HTTP/1.1
Host: www.example.ac.jp
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:30.0) Gecko/20100101 Firefox/30.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: ja,en-us;q=0.7,en;q=0.3
Accept-Encoding: gzip, deflate
リクエスト
Connection: keep-alive
HTTP/1.1 200 OK
Date: Thu, 12 Jun 2014 10:26:23 GMT
Server: Apache
Last-Modified: Thu, 12 Jun 2014 01:58:09 GMT
Etag: "37c-4fb99e47fee40"
Accept-Ranges: bytes
Content-Length: 892
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: text/html; charset=utf-8
Connection: keep-alive
Connection: close
レスポンス
1回目のHTTPリクエスト・レスポンス
GET /taro.html HTTP/1.1
Host: www.example.ac.jp
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:30.0) Gecko/20100101 Firefox/30.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: ja,en-us;q=0.7,en;q=0.3
Accept-Encoding: gzip, deflate
リクエスト
Connection: keep-alive
HTTP/1.1 200 OK
Date: Thu, 12 Jun 2014 10:26:23 GMT
Server: Apache
Last-Modified: Thu, 12 Jun 2014 01:58:09 GMT
Etag: "37c-4fb99e47fee40"
Accept-Ranges: bytes
② メッセージボディのサイズ
Content-Length: 892
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: text/html; charset=utf-8
レスポンス
メッセージボディのサイズ
レスポンス
HTTP/1.1 200 OK
Content-Length: 892
Content-Type: text/html; charset=utf-8
リクエスト
POST /test HTTP/1.1
Host: www.example.ac.jp
Content-Type: application/x-www-form-urlencoded
Content-Length: 19
qt=%E3%81%82&page=1
チャンク転送
The Open University of Japan was founded in 1983.
HTTP/1.1 200 OK
Content-Type: text/plain
Content-Length: 49
レスポンス
The Open University of Japan was founded in 1983.
チャンク転送
The Open University of Japan was founded in 1983.
HTTP/1.1 200 OK
Transfer-Encoding: chunked
Content-Type: text/plain
13
The Open University
d
of Japan was
11
founded in 1983.
0
レスポンス
チャンク転送
The Open University of Japan was founded in 1983.
HTTP/1.1 200 OK
Transfer-Encoding: chunked
Content-Type: text/plain
13
The Open University
d
of Japan was
11
founded in 1983.
0
レスポンス
チャンク転送
The Open University of Japan was founded in 1983.
HTTP/1.1 200 OK
Transfer-Encoding:
chunked
チャンクサイズ (十六進数)
Content-Type: text/plain
13
The Open University
d
of Japan was
11
founded in 1983.
0
チャンクデータ
レスポンス
チャンク転送
The Open University of Japan was founded in 1983.
HTTP/1.1 200 OK
Transfer-Encoding: chunked
Content-Type: text/plain
13
The Open University
d
of Japan was
11
founded in 1983.
0
レスポンス
チャンク転送
The Open University of Japan was founded in 1983.
HTTP/1.1 200 OK
Transfer-Encoding: chunked
Content-Type: text/plain
13
The Open University
d
of Japan was
11
founded in 1983.
0
レスポンス
チャンク転送
The Open University of Japan was founded in 1983.
HTTP/1.1 200 OK
Transfer-Encoding: chunked
Content-Type: text/plain
13
The Open University
d
of Japan was
11
founded in 1983.
0
レスポンス
1回目のHTTPリクエスト・レスポンス
GET /taro.html HTTP/1.1
Host: www.example.ac.jp
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:30.0) Gecko/20100101 Firefox/30.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
③ HTTPメソッド
Accept-Language: ja,en-us;q=0.7,en;q=0.3
Accept-Encoding: gzip, deflate
リクエスト
Connection: keep-alive
HTTP/1.1 200 OK
Date: Thu, 12 Jun 2014 10:26:23 GMT
Server: Apache
Last-Modified: Thu, 12 Jun 2014 01:58:09 GMT
Etag: "37c-4fb99e47fee40"
Accept-Ranges: bytes
Content-Length: 892
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: text/html; charset=utf-8
レスポンス
HTTPメソッド
GET
POST
DELETE
OPTIONS
HEAD
PUT
CONNECT
TRACE
HTTPメソッド
• GET ⋯ リソースの取得
– アドレスバーにURIを入力
– ハイパーリンクをクリック
• POST ⋯ 多目的
• PUT ⋯ リソースの作成・更新
• DELETE ⋯ リソースの削除
POSTメソッド
• メッセージボディを持った
リクエストを送信
1回目のHTTPリクエスト・レスポンス
GET /taro.html HTTP/1.1
Host: www.example.ac.jp
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:30.0) Gecko/20100101 Firefox/30.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: ja,en-us;q=0.7,en;q=0.3
Accept-Encoding: gzip, deflate
リクエスト
Connection: keep-alive
HTTP/1.1 200 OK
Date: Thu, 12 Jun 2014 10:26:23 GMT
Server: Apache
Last-Modified: Thu, 12 Jun 2014 01:58:09 GMT
④ ステータスコード
Etag: "37c-4fb99e47fee40"
Accept-Ranges: bytes
Content-Length: 892
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: text/html; charset=utf-8
レスポンス
ステータスコード
100
101
200
201
202
203
204
205
206
300
301
302
303
304
Continue
Switching Protocols
OK
Created
Accepted
Non-Authoritative
Information
No Content
Reset Content
Partial Content
Multiple Choices
Moved Permanently
Found
See Other
Not Modified
305
307
400
401
402
403
404
405
406
407
408
409
410
411
Use Proxy
Temporary Redirect
Bad Request
Unauthorized
Payment Required
Forbidden
Not Found
Method Not Allowed
Not Acceptable
Proxy Authentication
Required
Request Timeout
Conflict
Gone
Length Required
412
413
414
415
416
417
426
500
501
502
503
504
505
Precondition Failed
Payload Too Large
URI Too Long
Unsupported Media
Type
Range Not Satisfiable
Expectation Failed
Upgrade Required
Internal Server Error
Not Implemented
Bad Gateway
Service Unavailable
Gateway Timeout
HTTP Version Not
Supported
ステータスコードの分類
先頭の数字
意味
説明
1xx
情報提供
(Informational)
リクエストは受け付けられて、
処理を継続中である。
成功
リクエストは成功した。
2xx
(Successful)
3xx
リダイレクト
(Redirection)
4xx
5xx
クライアントエラー
リクエストを完了するためには、
さらなる動作が必要である。
(Client Error)
リクエストの方法を間違えてい
るか、受け入れられない。
サーバエラー
サーバ側で処理に失敗した。
(Server Error)
ステータスコード
100
101
200
201
202
203
204
205
206
300
301
302
303
304
Continue
Switching Protocols
OK
Created
Accepted
Non-Authoritative
Information
No Content
Reset Content
Partial Content
Multiple Choices
Moved Permanently
Found
See Other
Not Modified
305
307
400
401
402
403
404
405
406
407
408
409
410
411
Use Proxy
Temporary Redirect
Bad Request
Unauthorized
Payment Required
Forbidden
Not Found
Method Not Allowed
Not Acceptable
Proxy Authentication
Required
Request Timeout
Conflict
Gone
Length Required
412
413
414
415
416
417
426
500
501
502
503
504
505
Precondition Failed
Payload Too Large
URI Too Long
Unsupported Media
Type
Range Not Satisfiable
Expectation Failed
Upgrade Required
Internal Server Error
Not Implemented
Bad Gateway
Service Unavailable
Gateway Timeout
HTTP Version Not
Supported
ステータスコードの分類
先頭の数字
意味
説明
1xx
情報提供
(Informational)
リクエストは受け付けられて、
処理を継続中である。
成功
リクエストは成功した。
2xx
(Successful)
3xx
リダイレクト
(Redirection)
4xx
5xx
クライアントエラー
リクエストを完了するためには、
さらなる動作が必要である。
(Client Error)
リクエストの方法を間違えてい
るか、受け入れられない。
サーバエラー
サーバ側で処理に失敗した。
(Server Error)
ステータスコード
100
101
200
201
202
203
204
205
206
300
301
302
303
304
Continue
Switching Protocols
OK
Created
Accepted
Non-Authoritative
Information
No Content
Reset Content
Partial Content
Multiple Choices
Moved Permanently
Found
See Other
Not Modified
305
307
400
401
402
403
404
405
406
407
408
409
410
411
Use Proxy
Temporary Redirect
Bad Request
Unauthorized
Payment Required
Forbidden
Not Found
Method Not Allowed
Not Acceptable
Proxy Authentication
Required
Request Timeout
Conflict
Gone
Length Required
412
413
414
415
416
417
426
500
501
502
503
504
505
Precondition Failed
Payload Too Large
URI Too Long
Unsupported Media
Type
Range Not Satisfiable
Expectation Failed
Upgrade Required
Internal Server Error
Not Implemented
Bad Gateway
Service Unavailable
Gateway Timeout
HTTP Version Not
Supported
ステータスコード
100
101
200
201
202
203
204
205
206
300
301
302
303
304
Continue
Switching Protocols
OK
Created
Accepted
Non-Authoritative
Information
No Content
Reset Content
Partial Content
Multiple Choices
Moved Permanently
Found
See Other
Not Modified
305
307
400
401
402
403
404
405
406
407
408
409
410
411
Use Proxy
Temporary Redirect
Bad Request
Unauthorized
Payment Required
Forbidden
Not Found
Method Not Allowed
Not Acceptable
Proxy Authentication
Required
Request Timeout
Conflict
Gone
Length Required
412
413
414
415
416
417
426
500
501
502
503
504
505
Precondition Failed
Payload Too Large
URI Too Long
Unsupported Media
Type
Range Not Satisfiable
Expectation Failed
Upgrade Required
Internal Server Error
Not Implemented
Bad Gateway
Service Unavailable
Gateway Timeout
HTTP Version Not
Supported
ステータスコード404
レスポンス
HTTP/1.1 404 Not Found
Content-Length: 206
Content-Type: text/html; charset=iso-8859-1
<!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 /notfound was not found on this server.</p>
</body></html>
ステータスコード404
<!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 /notfound was not found on this server.</p>
</body></html>
ステータスコードの分類
先頭の数字
意味
説明
1xx
情報提供
(Informational)
リクエストは受け付けられて、
処理を継続中である。
成功
リクエストは成功した。
2xx
(Successful)
3xx
リダイレクト
(Redirection)
4xx
5xx
クライアントエラー
リクエストを完了するためには、
さらなる動作が必要である。
(Client Error)
リクエストの方法を間違えてい
るか、受け入れられない。
サーバエラー
サーバ側で処理に失敗した。
(Server Error)
ステータスコード
100
101
200
201
202
203
204
205
206
300
301
302
303
304
Continue
Switching Protocols
OK
Created
Accepted
Non-Authoritative
Information
No Content
Reset Content
Partial Content
Multiple Choices
Moved Permanently
Found
See Other
Not Modified
305
307
400
401
402
403
404
405
406
407
408
409
410
411
Use Proxy
Temporary Redirect
Bad Request
Unauthorized
Payment Required
Forbidden
Not Found
Method Not Allowed
Not Acceptable
Proxy Authentication
Required
Request Timeout
Conflict
Gone
Length Required
412
413
414
415
416
417
426
500
501
502
503
504
505
Precondition Failed
Payload Too Large
URI Too Long
Unsupported Media
Type
Range Not Satisfiable
Expectation Failed
Upgrade Required
Internal Server Error
Not Implemented
Bad Gateway
Service Unavailable
Gateway Timeout
HTTP Version Not
Supported
ステータスコード301
• リソースが恒久的に移動した
• Locationヘッダの値に移動先のURI
ステータスコード301
http://www.example.ac.jp/oldpath  http://www.example.ac.jp/newpath
GET /oldpath HTTP/1.1
Host: www.example.ac.jp
リクエスト
HTTP/1.1 301 Moved Permanently
Location: http://www.example.ac.jp/newpath
Content-Length: 240
Content-Type: text/html; charset=iso-8859-1
レスポンス
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>301 Moved Permanently</title>
</head><body>
<h1>Moved Permanently</h1>
<p>The document has moved <a href="http://www.example.ac.jp/newpath">here</a>.</p>
</body></html>
ステータスコード301
ステータスコードの分類
先頭の数字
意味
説明
1xx
情報提供
(Informational)
リクエストは受け付けられて、
処理を継続中である。
成功
リクエストは成功した。
2xx
(Successful)
3xx
リダイレクト
(Redirection)
4xx
5xx
クライアントエラー
リクエストを完了するためには、
さらなる動作が必要である。
(Client Error)
リクエストの方法を間違えてい
るか、受け入れられない。
サーバエラー
サーバ側で処理に失敗した。
(Server Error)
ステータスコード
100
101
200
201
202
203
204
205
206
300
301
302
303
304
Continue
Switching Protocols
OK
Created
Accepted
Non-Authoritative
Information
No Content
Reset Content
Partial Content
Multiple Choices
Moved Permanently
Found
See Other
Not Modified
305
307
400
401
402
403
404
405
406
407
408
409
410
411
Use Proxy
Temporary Redirect
Bad Request
Unauthorized
Payment Required
Forbidden
Not Found
Method Not Allowed
Not Acceptable
Proxy Authentication
Required
Request Timeout
Conflict
Gone
Length Required
412
413
414
415
416
417
426
500
501
502
503
504
505
Precondition Failed
Payload Too Large
URI Too Long
Unsupported Media
Type
Range Not Satisfiable
Expectation Failed
Upgrade Required
Internal Server Error
Not Implemented
Bad Gateway
Service Unavailable
Gateway Timeout
HTTP Version Not
Supported
ステータスコード
100
101
200
201
202
203
204
205
206
300
301
302
303
304
Continue
Switching Protocols
OK
Created
Accepted
Non-Authoritative
Information
No Content
Reset Content
Partial Content
Multiple Choices
Moved Permanently
Found
See Other
Not Modified
305
307
400
401
402
403
404
405
406
407
408
409
410
411
Use Proxy
Temporary Redirect
Bad Request
Unauthorized
Payment Required
Forbidden
Not Found
Method Not Allowed
Not Acceptable
Proxy Authentication
Required
Request Timeout
Conflict
Gone
Length Required
412
413
414
415
416
417
426
500
501
502
503
504
505
Precondition Failed
Payload Too Large
URI Too Long
Unsupported Media
Type
Range Not Satisfiable
Expectation Failed
Upgrade Required
Internal Server Error
Not Implemented
Bad Gateway
Service Unavailable
Gateway Timeout
HTTP Version Not
Supported
ステータスコード503
GET / HTTP/1.1
Host: www.example.ac.jp
リクエスト
HTTP/1.1 503 Service Unavailable
レスポンス
Date: Sun, 15 Jun 2014 06:20:53 GMT
Content-Length: 299
Retry-After: Sun, 15 Jun 2014 09:59:59 GMT
Content-Type: text/html; charset=iso-8859-1
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>503 Service Unavailable</title>
(以下略)
ステータスコード503
ステータスコード503
GET / HTTP/1.1
Host: www.example.ac.jp
リクエスト
HTTP/1.1 503 Service Unavailable
レスポンス
Date: Sun, 15 Jun 2014 06:20:53 GMT
Content-Length: 299
Retry-After: Sun, 15 Jun 2014 09:59:59 GMT
Content-Type: text/html; charset=iso-8859-1
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>503 Service Unavailable</title>
(以下略)
メディアタイプ
リクエスト
GET /taro.html HTTP/1.1
Host: www.example.ac.jp
レスポンス
HTTP/1.1 200 OK
Content-Length: 892
Content-Type: text/html; charset=utf-8
メディアタイプ
リクエスト
GET /taro.html HTTP/1.1
Host: www.example.ac.jp
レスポンス
HTTP/1.1 200 OK
Content-Length: 892
Content-Type: text/plain; charset=utf-8
第5回の内容
• HTTPの規格
• HTTPメッセージの基本
•
•
•
•
•
メッセージの構造
持続的接続
メッセージボディのサイズとチャンク転送
HTTPメソッド
ステータスコード
Fly UP