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
タブを全て閉じる