HttpWebResponse.Headers プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > HttpWebResponse.Headers プロパティの意味・解説 

HttpWebResponse.Headers プロパティ

応答関連付けられているヘッダーサーバーから取得します

名前空間: System.Net
アセンブリ: System (system.dll 内)
構文構文

Public Overrides ReadOnly
 Property Headers As WebHeaderCollection
Dim instance As HttpWebResponse
Dim value As WebHeaderCollection

value = instance.Headers
public override WebHeaderCollection Headers { get;
 }
public:
virtual property WebHeaderCollection^ Headers {
    WebHeaderCollection^ get () override;
}
/** @property */
public WebHeaderCollection get_Headers ()
public override function get
 Headers () : WebHeaderCollection

プロパティ
応答返されるヘッダー情報格納する WebHeaderCollection。

例外例外
解説解説
使用例使用例

すべての応答ヘッダー内容コンソール出力する例を次に示します

' Creates an HttpWebRequest with the specified URL. 
Dim myHttpWebRequest As HttpWebRequest = CType(WebRequest.Create(url),
 HttpWebRequest)
' Sends the HttpWebRequest and waits for a response.
Dim myHttpWebResponse As HttpWebResponse =
 CType(myHttpWebRequest.GetResponse(), HttpWebResponse)
' Displays all the Headers present in the response received from the
 URI.
Console.WriteLine(ControlChars.Lf + ControlChars.Cr + "The following
 headers were received in the response")
'The Headers property is a WebHeaderCollection. Use it's properties
 to traverse the collection and display each header.
Dim i As Integer
While i < myHttpWebResponse.Headers.Count
    Console.WriteLine(ControlChars.Cr + "Header Name:{0}, Value
 :{1}", myHttpWebResponse.Headers.Keys(i), myHttpWebResponse.Headers(i))
  i = i + 1
End While
myHttpWebResponse.Close()
// Creates an HttpWebRequest for the specified URL. 
HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create(url); 
// Sends the HttpWebRequest and waits for response.
HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse();
 
                        
// Displays all the headers present in the response received from the
 URI.
Console.WriteLine("\r\nThe following headers were received in
 the response:");
// Displays each header and it's key associated with the response.
for(int i=0; i < myHttpWebResponse.Headers.Count;
 ++i)  
    Console.WriteLine("\nHeader Name:{0}, Value :{1}",myHttpWebResponse.Headers.Keys[i],myHttpWebResponse.Headers[i]);
 
// Releases the resources of the response.
myHttpWebResponse.Close(); 
// Creates an HttpWebRequest for the specified URL.
HttpWebRequest^ myHttpWebRequest = dynamic_cast<HttpWebRequest^>(WebRequest::Create(
 url ));

// Sends the HttpWebRequest and waits for response.
HttpWebResponse^ myHttpWebResponse = dynamic_cast<HttpWebResponse^>(myHttpWebRequest->GetResponse());

// Displays all the headers present in the response received from the
 URI.
Console::WriteLine( "\r\nThe following headers were received in
 the response:" );

// Displays each header and its key associated with the response.
for ( int i = 0; i < myHttpWebResponse->Headers->Count;
 ++i )
   Console::WriteLine( "\nHeader Name: {0}, Value : {1}",
      myHttpWebResponse->Headers->Keys[ i ],
      myHttpWebResponse->Headers[ (System::Net::HttpRequestHeader)i ] );

// Releases the resources of the response.
myHttpWebResponse->Close();
// Creates an HttpWebRequest for the specified URL. 
HttpWebRequest myHttpWebRequest = (HttpWebRequest)
    WebRequest.Create(url);
// Sends the HttpWebRequest and waits for response.
HttpWebResponse myHttpWebResponse = (HttpWebResponse)
    myHttpWebRequest.GetResponse();
// Displays all the headers present in the response 
// received from the URI.
Console.WriteLine("\r\nThe following headers were received"
    + " in the response:");
// Displays each header and it's key associated with the response.
for (int i = 0; i < myHttpWebResponse.get_Headers().get_Count();
    ++i) {
    Console.WriteLine("\nHeader Name:{0}, Value :{1}", 
        myHttpWebResponse.get_Headers().get_Keys().get_Item(i), 
        myHttpWebResponse.get_Headers().get_Item(i));
}  // Releases the resources of the response.

myHttpWebResponse.Close();
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照


このページでは「.NET Framework クラス ライブラリ リファレンス」からHttpWebResponse.Headers プロパティを検索した結果を表示しています。
Weblioに収録されているすべての辞書からHttpWebResponse.Headers プロパティを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からHttpWebResponse.Headers プロパティ を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「HttpWebResponse.Headers プロパティ」の関連用語

HttpWebResponse.Headers プロパティのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



HttpWebResponse.Headers プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS