From 76ad2def9076400c5c55d43aa1f58e6a291791d3 Mon Sep 17 00:00:00 2001 From: Masahiro FUJIMOTO Date: Sat, 29 Jan 2022 22:55:27 +0900 Subject: XMLHttpRequest のメソッドを移行 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xmlhttprequest/getresponseheader/index.html | 90 ---------------------- 1 file changed, 90 deletions(-) delete mode 100644 files/ja/web/api/xmlhttprequest/getresponseheader/index.html (limited to 'files/ja/web/api/xmlhttprequest/getresponseheader/index.html') diff --git a/files/ja/web/api/xmlhttprequest/getresponseheader/index.html b/files/ja/web/api/xmlhttprequest/getresponseheader/index.html deleted file mode 100644 index 73ef9e1a35..0000000000 --- a/files/ja/web/api/xmlhttprequest/getresponseheader/index.html +++ /dev/null @@ -1,90 +0,0 @@ ---- -title: XMLHttpRequest.getResponseHeader() -slug: Web/API/XMLHttpRequest/getResponseHeader -tags: - - API - - HTTP - - HTTP ヘッダー - - Reference - - XHR - - XMLHttpRequest - - getResponseHeader - - ヘッダー - - ヘッダーの取得 - - メソッド -translation_of: Web/API/XMLHttpRequest/getResponseHeader ---- -
{{APIRef('XMLHttpRequest')}}
- -

{{DOMxRef("XMLHttpRequest")}} の getResponseHeader() メソッドは、特定のヘッダー値のテキストを含んだ文字列を返します。同じ名前で複数のレスポンスヘッダーがあった場合、値はコンマと空白で区切って値を接続した単一の文字列として返されます。 getResponseHeader() メソッドは値を UTF バイトシーケンスとして返します。

- -
-

メモ: ヘッダー名の検索は、大文字小文字の区別がありません。

-
- -

ヘッダーすべての生の文字列を取得する必要がある場合は、生のヘッダー文字列全体を返す {{DOMxRef("XMLHttpRequest.getAllResponseHeaders", "getAllResponseHeaders()")}} メソッドを使用してください。

- -

構文

- -
var myHeader = XMLHttpRequest.getResponseHeader(headerName);
- -

引数

- -
-
headerName
-
{{DOMxRef("ByteString")}} で、テキスト値を取得したいヘッダーの名前を示します。
-
- -

返値

- -

ヘッダーのテキスト値を表す {{DOMxRef("ByteString")}}、または、レスポンスがまだ受信されていないか、そのヘッダーがレスポンスに存在しなければ null です。

- -

- -

この例では、リクエストが生成されて送信され、そして {{Event("readystatechange")}} ハンドラーを設定してヘッダーが純真で来たことを示す {{DOMxRef("XMLHttpRequest.readyState", "readyState")}} を監視します。その時が来たら、 {{httpheader("Content-Type")}} ヘッダーの値を読み取ります。 Content-Type が求められる値でない場合、 {{DOMxRef("XMLHttpRequest")}} は {{DOMxRef("XMLHttpRequest.abort", "abort()")}} を呼び出してキャンセルします。

- -
var client = new XMLHttpRequest();
-client.open("GET", "unicorns-are-teh-awesome.txt", true);
-client.send();
-
-client.onreadystatechange = function() {
-  if(this.readyState == this.HEADERS_RECEIVED) {
-    var contentType = client.getResponseHeader("Content-Type");
-    if (contentType != my_expected_type) {
-      client.abort();
-    }
-  }
-}
- -

仕様書

- - - - - - - - - - - - - - - - -
仕様書状態備考
{{SpecName("XMLHttpRequest", "#dom-xmlhttprequest-getresponseheader", "getResponseHeader()")}}{{Spec2("XMLHttpRequest")}}WHATWG living standard
- -

ブラウザーの対応

- -
{{Compat("api.XMLHttpRequest.getResponseHeader")}}
- -

関連情報

- - -- cgit v1.2.3-54-g00ecf