aboutsummaryrefslogtreecommitdiff
path: root/files/ja/web/api/xmlhttprequest/getresponseheader/index.md
diff options
context:
space:
mode:
authorMasahiro FUJIMOTO <mfujimot@gmail.com>2022-01-29 22:55:27 +0900
committerMasahiro FUJIMOTO <mfujimot@gmail.com>2022-02-05 13:19:42 +0900
commit76ad2def9076400c5c55d43aa1f58e6a291791d3 (patch)
tree3332a57023aa17dab283a596a1d2058c45284a92 /files/ja/web/api/xmlhttprequest/getresponseheader/index.md
parent09aa8bd8a3deb25db2345e0ff157f663e88a78ed (diff)
downloadtranslated-content-76ad2def9076400c5c55d43aa1f58e6a291791d3.tar.gz
translated-content-76ad2def9076400c5c55d43aa1f58e6a291791d3.tar.bz2
translated-content-76ad2def9076400c5c55d43aa1f58e6a291791d3.zip
XMLHttpRequest のメソッドを移行
Diffstat (limited to 'files/ja/web/api/xmlhttprequest/getresponseheader/index.md')
-rw-r--r--files/ja/web/api/xmlhttprequest/getresponseheader/index.md90
1 files changed, 90 insertions, 0 deletions
diff --git a/files/ja/web/api/xmlhttprequest/getresponseheader/index.md b/files/ja/web/api/xmlhttprequest/getresponseheader/index.md
new file mode 100644
index 0000000000..73ef9e1a35
--- /dev/null
+++ b/files/ja/web/api/xmlhttprequest/getresponseheader/index.md
@@ -0,0 +1,90 @@
+---
+title: XMLHttpRequest.getResponseHeader()
+slug: Web/API/XMLHttpRequest/getResponseHeader
+tags:
+ - API
+ - HTTP
+ - HTTP ヘッダー
+ - Reference
+ - XHR
+ - XMLHttpRequest
+ - getResponseHeader
+ - ヘッダー
+ - ヘッダーの取得
+ - メソッド
+translation_of: Web/API/XMLHttpRequest/getResponseHeader
+---
+<div>{{APIRef('XMLHttpRequest')}}</div>
+
+<p><span class="seoSummary">{{DOMxRef("XMLHttpRequest")}} の <strong><code>getResponseHeader()</code></strong> メソッドは、特定のヘッダー値のテキストを含んだ文字列を返します。</span>同じ名前で複数のレスポンスヘッダーがあった場合、値はコンマと空白で区切って値を接続した単一の文字列として返されます。 <code>getResponseHeader()</code> メソッドは値を UTF バイトシーケンスとして返します。</p>
+
+<div class="note">
+<p><strong>メモ:</strong> ヘッダー名の検索は、大文字小文字の区別がありません。</p>
+</div>
+
+<p>ヘッダーすべての生の文字列を取得する必要がある場合は、生のヘッダー文字列全体を返す {{DOMxRef("XMLHttpRequest.getAllResponseHeaders", "getAllResponseHeaders()")}} メソッドを使用してください。</p>
+
+<h2 id="構文">構文</h2>
+
+<pre class="syntaxbox">var <var>myHeader</var> = <var>XMLHttpRequest</var>.getResponseHeader(<var>headerName</var>);</pre>
+
+<h3 id="Parameters" name="Parameters">引数</h3>
+
+<dl>
+ <dt><var>headerName</var></dt>
+ <dd>{{DOMxRef("ByteString")}} で、テキスト値を取得したいヘッダーの名前を示します。</dd>
+</dl>
+
+<h3 id="Return_value" name="Return_value">返値</h3>
+
+<p>ヘッダーのテキスト値を表す {{DOMxRef("ByteString")}}、または、レスポンスがまだ受信されていないか、そのヘッダーがレスポンスに存在しなければ <code>null</code> です。</p>
+
+<h2 id="Example" name="Example">例</h2>
+
+<p>この例では、リクエストが生成されて送信され、そして {{Event("readystatechange")}} ハンドラーを設定してヘッダーが純真で来たことを示す {{DOMxRef("XMLHttpRequest.readyState", "readyState")}} を監視します。その時が来たら、 {{httpheader("Content-Type")}} ヘッダーの値を読み取ります。 <code>Content-Type</code> が求められる値でない場合、 {{DOMxRef("XMLHttpRequest")}} は {{DOMxRef("XMLHttpRequest.abort", "abort()")}} を呼び出してキャンセルします。</p>
+
+<pre class="brush: js">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();
+ }
+ }
+}</pre>
+
+<h2 id="Specifications" name="Specifications">仕様書</h2>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">仕様書</th>
+ <th scope="col">状態</th>
+ <th scope="col">備考</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>{{SpecName("XMLHttpRequest", "#dom-xmlhttprequest-getresponseheader", "getResponseHeader()")}}</td>
+ <td>{{Spec2("XMLHttpRequest")}}</td>
+ <td>WHATWG living standard</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザーの対応</h2>
+
+<div>{{Compat("api.XMLHttpRequest.getResponseHeader")}}</div>
+
+<h2 id="See_also" name="See_also">関連情報</h2>
+
+<ul>
+ <li><a href="/ja/docs/Web/API/XMLHttpRequest/Using_XMLHttpRequest">XMLHttpRequest の使用</a></li>
+ <li><a href="/ja/docs/Web/HTTP/Headers">HTTP ヘッダー</a></li>
+ <li>{{DOMxRef("XMLHttpRequest.getAllResponseHeaders", "getAllResponseHeaders()")}}</li>
+ <li>{{DOMxRef("XMLHttpRequest.response", "response")}}</li>
+ <li>リクエストヘッダーの設定: {{domxref("XMLHttpRequest.setRequestHeader", "setRequestHeader()")}}</li>
+</ul>