markdown
HTTP の基本md cd65c2e
lecture/information/networks/http-basics.lecture.n.md
Download PDF

HTTP の基本きほん

date2026-07-14document_iddoc_8e935edb23d90a937b6ae5edc6d4c81ddescriptionHTTPの資源指向の要求・応答意味論、メソッド、状態コード、HTTPS、各バージョンの転送方式を説明する。prerequisitesネットワークの基本 / TCPとIPの基本 / DNSの基本type講義statusactiverelateddata/lecture/information/networks/computer-networks-portal.lecture.n.md / data/lecture/information/networks/tcp-and-ip-basics.lecture.n.md / data/lecture/information/networks/dns-basics.lecture.n.md / data/lecture/information/database/database-portal.lecture.n.md
informationnetworksundergraduatelecture
data/lecture/information/networks/dns-basics.lecture.n.md

1導入どうにゅう

この講義こうぎでは、クライアントが資源しげんに対たいする要求ようきゅうを送信そうしんし、サーバが処理結果しょりけっかを応答おうとうするためのHTTPHypertext Transfer Protocolの意味論いみろんを説明せつめいする。HTTP の要求ようきゅうと応答おうとうを、IP によるパケット転送てんそうやトランスポート層そうの機能きのうと区別くべつする。

2資源しげんと表現ひょうげん

資源しげんResourceとは、HTTP による操作そうさの対象たいしょうであり、URIUniform Resource Identifierによって識別しきべつされる。Web ページ、画像がぞう、API が管理かんりするデータなどを資源しげんとして扱あつかえる。

表現ひょうげんRepresentationとは、ある時点じてんにおける資源しげんの状態じょうたいを表現ひょうげんするデータである。同一どういつの資源しげんが、HTML、JSON、画像形式がぞうけいしきなどの異ことなる表現ひょうげんを提供ていきょうすることもある。この講義こうぎでは、資源しげんへのアクセスに用もちいるURIをURLUniform Resource Locatorと呼よぶ。

HTTP では、クライアントClientが要求ようきゅうを送信そうしんし、サーバServerがその要求ようきゅうを処理しょりして応答おうとうを返送へんそうする。この役割やくわりは個々ここの交換こうかんに対たいして定さだまり、ブラウザに限定げんていされない。

3要求ようきゅうと応答おうとうの意味論いみろん

HTTP 要求ようきゅうは、概念的がいねんてきに次つぎの要素ようそから構成こうせいされる。

  • メソッドMethod: 資源しげんに対たいして要求ようきゅうする意味いみを指定していする。
  • 要求対象ようきゅうたいしょうRequest target: 操作そうさの対象たいしょうを指定していする。
  • フィールドField: 表現形式ひょうげんけいしき、認証にんしょう、キャッシュなどに関かんするメタデータを伝達でんたつする。
  • 内容ないようContent: 必要ひつような場合ばあいに、処理対象しょりたいしょうとなる表現ひょうげんを伝達でんたつする。

HTTP 応答おうとうは、要求ようきゅうの処理結果しょりけっかを分類ぶんるいする状態じょうたいコードStatus code、フィールド、および必要ひつように応おうじた内容ないようから構成こうせいされる。状態じょうたいコードはサーバ自体じたいの状態じょうたいではなく、その要求ようきゅうに対たいする処理結果しょりけっかを表あらわす。

4HTTP/1.1 のメッセージ例れい

HTTP/1.1 は、開始行かいしぎょうとフィールドをテキスト形式けいしきで表現ひょうげんする。たとえば、次つぎの要求行ようきゅうぎょうは /index.html を要求対象ようきゅうたいしょうとする GET 要求ようきゅうである。

http
GET /index.html HTTP/1.1
Host: example.com
Accept: text/html

応答おうとうの開始行かいしぎょうには、HTTP のバージョン、状態じょうたいコード、理由句りゆうくが含ふくまれる。

http
HTTP/1.1 200 OK
Content-Type: text/html

このテキスト形式けいしきは HTTP/1.1 の表現方法ひょうげんほうほうである。HTTP/2 と HTTP/3 は要求行ようきゅうぎょうを使用しようせず、HTTP の意味いみをバイナリフレームで符号化ふごうかする。

5メソッドの性質せいしつ

GETGETは、要求対象ようきゅうたいしょうとなる資源しげんについて、選択せんたくされた現在げんざいの表現ひょうげんの転送てんそうを要求ようきゅうする。GET は安全あんぜんSafeなメソッドとして定義ていぎされ、クライアントはサーバの状態変更じょうたいへんこうを要求ようきゅうしない。また、同一どういつの GET を複数回ふくすうかい実行じっこうしても、意図いとされるサーバ上じょうの効果こうかは一回いっかいの実行じっこうと同おなじである。この性質せいしつを冪等べきとうIdempotentという。ただし、アクセスログの記録きろくなどの付随的ふずいてきな変化へんかは許容きょようされる。

POSTPOSTは、要求ようきゅうに含ふくまれる表現ひょうげんを、要求対象ようきゅうたいしょうとなる資源しげんに固有こゆうの意味いみで処理しょりするよう要求ようきゅうする。フォームの送信そうしん、新あらたな資源しげんの生成せいせい、処理しょりの起動きどうなどに利用りようされ得うるため、POST を単たんなるファイル送信そうしんと定義ていぎすることはできない。POST は一般いっぱんに安全あんぜんでも冪等べきとうでもない。

6状態じょうたいコード

状態じょうたいコードの先頭桁せんとうけたは、処理結果しょりけっかを次つぎのように分類ぶんるいする。

  • 1xx: 情報応答じょうほうおうとう
  • 2xx: 成功せいこう
  • 3xx: リダイレクション
  • 4xx: クライアントエラー
  • 5xx: サーバエラー

200 OK は要求ようきゅうが成功せいこうしたことを表あらわす。404 Not Found は、サーバが要求対象ようきゅうたいしょうの現在げんざいの表現ひょうげんを発見はっけんできない、またはその存在そんざいを開示かいじしないことを表あらわす。したがって、404 だけから資源しげんが永久えいきゅうに存在そんざいしないとは断定だんていできない。

7HTTPS と TLS

HTTPSHTTPSは、TLSの機能きのうによって保護ほごされたHTTP通信つうしんを表あらわす。HTTP/1.1とHTTP/2ではTLSTransport Layer SecurityをTCP上じょうで使用しようし、HTTP/3ではTLSの暗号機能あんごうきのうとハンドシェイクがQUICへ統合とうごうされる。TLSは通信内容つうしんないようの機密性きみつせいと完全性かんぜんせいを保護ほごし、証明書しょうめいしょの検証けんしょうを通つうじて通常つうじょうはサーバを認証にんしょうする。HTTPSはHTTPの要求ようきゅう・応答おうとうの意味いみを変更へんこうしない。また、TLSによる認証にんしょうは、サーバが提供ていきょうする情報内容じょうほうないようの正確性せいかくせいまで保証ほしょうするものではない。

8HTTP のバージョンと転送方式てんそうほうしき

バージョン主おもな下位転送かいてんそうHTTP メッセージの表現ひょうげん
HTTP/1.1TCPテキスト形式けいしきの開始行かいしぎょうとフィールド
HTTP/2TCPバイナリフレーム、多重化たじゅうか
HTTP/3UDP 上じょうの QUICバイナリフレーム、QUIC ストリームによる多重化たじゅうか

資源しげん、メソッド、状態じょうたいコードなどの HTTP の意味論いみろんは、これらのバージョンで概おおむね共通きょうつうする。一方いっぽう、符号化ふごうかと下位かいの転送方式てんそうほうしきは異ことなる。したがって、HTTP が常つねに TCP を利用りようするとは限かぎらない。

9DNS および下位層かいそうとの関係かんけい

URL にドメイン名めいが含ふくまれる典型的てんけいてきな Web アクセスでは、クライアントは DNS による名前解決なまえかいけつの後あと、選択せんたくした IP アドレスへ接続せつぞくし、HTTP の要求ようきゅうを送信そうしんする。ただし、DNS は HTTP の意味論いみろんの一部いちぶではなく、キャッシュされた結果けっかや IP アドレスを直接ちょくせつ使用しようする場合ばあいもある。

IP はパケットを宛先あてさきへ転送てんそうし、TCP または QUIC は HTTP メッセージを運搬うんぱんするための機能きのうを提供ていきょうする。HTTP は、その上うえで資源しげんに対たいする要求ようきゅうと応答おうとうの意味いみを規定きていする。

10要点ようてん

  • HTTP は、URI で識別しきべつされる資源しげんに対たいする要求ようきゅうと応答おうとうの意味論いみろんを規定きていする。
  • メソッドは要求ようきゅうの意味いみを、状態じょうたいコードは処理結果しょりけっかの分類ぶんるいを表あらわす。
  • HTTPS は HTTP を TLS で保護ほごする。HTTP/1.1 と HTTP/2 は通常つうじょう TCP を、HTTP/3 は QUIC を利用りようする。

11次つぎに進すすむ講義こうぎ

data/lecture/information/database/database-portal.lecture.n.md

HTTP Fundamentals

data/lecture/information/networks/dns-basics.lecture.n.md

1Introduction

This lecture explains the semantics of HTTPHypertext Transfer Protocol, through which a client sends a request concerning a resource and a server responds with the result of processing that request. It distinguishes HTTP requests and responses from IP packet forwarding and transport-layer functions.

2Resources and Representations

A resourceResource is a target of HTTP operations and is identified by a URIUniform Resource Identifier. Web pages, images, and data managed by an API can all be treated as resources.

A representationRepresentation is data that represents the state of a resource at a particular time. A single resource can provide representations in HTML, JSON, image formats, or other forms. In this lecture, a URI used to access a resource is called a URLUniform Resource Locator.

In HTTP, a clientClient sends a request, and a serverServer processes that request and returns a response. These roles are defined for each exchange and are not limited to web browsers.

3Request and Response Semantics

Conceptually, an HTTP request contains the following elements:

  • a methodMethod, which specifies the requested semantics for the resource;
  • a request targetRequest target, which identifies the target of the operation;
  • fieldsField, which convey metadata concerning representation formats, authentication, caching, and other matters; and
  • optional contentContent, which conveys a representation to be processed when required.

An HTTP response contains a status codeStatus code that classifies the result of processing the request, fields, and optional content. A status code describes the result for that request, not the state of the server itself.

4An HTTP/1.1 Message Example

HTTP/1.1 represents the start line and fields as text. The following request line is a GET request whose request target is /index.html.

http
GET /index.html HTTP/1.1
Host: example.com
Accept: text/html

The response start line contains the HTTP version, status code, and reason phrase.

http
HTTP/1.1 200 OK
Content-Type: text/html

This textual format is an HTTP/1.1 representation. HTTP/2 and HTTP/3 do not use request lines; they encode HTTP semantics in binary frames.

5Method Properties

GETGET requests transfer of a current selected representation for the target resource. GET is defined as a safeSafe method: the client does not request a change to server state. GET is also idempotentIdempotent: the intended effect on the server of several identical GET requests is the same as the effect of one such request. Incidental effects such as access logging remain permissible.

POSTPOST requests that the target resource process the enclosed representation according to its resource-specific semantics. It can submit a form, create a resource, or initiate a process, so POST cannot be defined merely as file transmission. POST is generally neither safe nor idempotent.

6Status Codes

The first digit of a status code classifies the processing result as follows:

  • 1xx: informational responses;
  • 2xx: successful responses;
  • 3xx: redirection messages;
  • 4xx: client errors; and
  • 5xx: server errors.

200 OK indicates that the request succeeded. 404 Not Found indicates that the server cannot find a current representation for the target resource or is unwilling to disclose that one exists. A 404 response alone therefore does not prove that the resource will never exist.

7HTTPS and TLS

HTTPSHTTPS denotes HTTP communication protected by TLS functions. HTTP/1.1 and HTTP/2 use TLSTransport Layer Security over TCP, while HTTP/3 integrates the TLS handshake and cryptographic functions into QUIC. TLS protects the confidentiality and integrity of communication and normally authenticates the server through certificate validation. HTTPS does not change HTTP request and response semantics. Authentication by TLS also does not guarantee the factual correctness of information supplied by the server.

8HTTP Versions and Transport

VersionPrimary underlying transportHTTP message representation
HTTP/1.1TCPTextual start lines and fields
HTTP/2TCPBinary frames and multiplexing
HTTP/3QUIC over UDPBinary frames and multiplexing over QUIC streams

HTTP semantics such as resources, methods, and status codes are largely common across these versions. Their encodings and underlying transports differ, however. HTTP does not therefore always use TCP.

9Relationship to DNS and Lower Layers

In a typical web access whose URL contains a domain name, a client resolves the name through DNS, connects to a selected IP address, and sends an HTTP request. DNS is not part of HTTP semantics, however, and a client may instead use a cached result or an IP address directly.

IP forwards packets toward their destination. TCP or QUIC provides functions that carry HTTP messages. Above them, HTTP defines the semantics of requests and responses concerning resources.

10Key Points

  • HTTP defines request and response semantics for resources identified by URIs.
  • A method specifies request semantics, while a status code classifies the processing result.
  • HTTPS protects HTTP with TLS. HTTP/1.1 and HTTP/2 normally use TCP, whereas HTTP/3 uses QUIC.

11Next Lecture

data/lecture/information/database/database-portal.lecture.n.md
raw .n.md をコピー
loc をコピー (filepath:line ~ line)
copy share link
copy encoded share link
path をコピー
copy share link
copy encoded share link
copy share link
copy encoded share link
タブを全て閉じる