HttpRequestとは? わかりやすく解説

Weblio 辞書 > コンピュータ > PHP関数リファレンス > HttpRequestの意味・解説 

http_request

(No version information available, might be only in CVS)
http_request — 独自のリクエストを実行する

説明

string http_request ( int method [, string url [, string body [, array options [, array &info]]]] )
指定した url に対して独自の HTTP リクエストを実行します。
使用可能なパラメータおよびオプションの一覧は、 http_get() を参照ください。

パラメータ

method
リクエストメソッド。
url
URL。
body
リクエストの本文。
options
リクエストのオプション
info
リクエスト/レスポンス の情報

返り値

成功した場合は HTTP レスポンスを文字列で、失敗した場合は FALSE を返します。

HttpRequest クラス

Web 要求中にクライアントから送信されHTTP 値を ASP.NET読み取ることができるようにします。

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

Public NotInheritable Class
 HttpRequest
public sealed class HttpRequest
public ref class HttpRequest sealed
public final class HttpRequest
解説解説
使用例使用例

StreamWriter クラス使用してHttpRequest クラス複数プロパティ値をファイル書き込むコード例次に示します文字列型プロパティ場合ファイル書き込むときに値が HTML エンコードされますコレクションを表すプロパティでは、格納されているキーと値の各ペアがループ処理でファイル書き込まれます。

<%@ Page Language="VB" %>
<%@ import Namespace="System.Threading"
 %>
<%@ import Namespace="System.IO"
 %>
<script runat="server">

    '  NOTE: To use this sample, create a c:\temp\CS folder,
    '  add the ASP.NET account (in IIS 5.x <machinename>\ASPNET
,
    '  in IIS 6.x NETWORK SERVICE), and give it write permissions
    '  to the folder.

    Private Const INFO_DIR As
 String = "c:\temp\VB\RequestDetails"
    Public Shared requestCount As
 Integer

    Private Sub Page_Load(sender As
 Object, e As System.EventArgs)

        ' Create a variable to use when iterating
        ' through the UserLanguages property.
        Dim langCount As Integer

        ' Create a counter to name the file.
        Dim requestNumber As Integer
 = _
          Interlocked.Increment(requestCount)

        ' Create the file to contain information about the request.
        Dim strFilePath As String
 = INFO_DIR & requestNumber.ToString() & ".txt"
        Dim sw As StreamWriter = File.CreateText(strFilePath)

        Try

            ' Write request information to the file with HTML encoding.
            sw.WriteLine(Server.HtmlEncode(DateTime.Now.ToString()))
            sw.WriteLine(Server.HtmlEncode(Request.CurrentExecutionFilePath))
            sw.WriteLine(Server.HtmlEncode(Request.ApplicationPath))
            sw.WriteLine(Server.HtmlEncode(Request.FilePath))
            sw.WriteLine(Server.HtmlEncode(Request.Path))

            ' Iterate through the Form collection and write
            ' the values to the file with HTML encoding.
            For Each s As
 String In Request.Form
                sw.WriteLine("Form: " & Server.HtmlEncode(s))
            Next s

            ' Write the PathInfo property value
            ' or a string if it is empty.
            If Request.PathInfo = String.Empty
 Then
                sw.WriteLine("The PathInfo property contains no
 information.")
            Else
                sw.WriteLine(Server.HtmlEncode(Request.PathInfo))
            End If

            ' Write request information to the file with HTML encoding.
            sw.WriteLine(Server.HtmlEncode(Request.PhysicalApplicationPath))
            sw.WriteLine(Server.HtmlEncode(Request.PhysicalPath))
            sw.WriteLine(Server.HtmlEncode(Request.RawUrl))

            ' Write a message to the file dependent upon
            ' the value of the TotalBytes property.
            If Request.TotalBytes > 1000 Then
                sw.WriteLine("The request is 1KB or greater")
            Else
                sw.WriteLine("The request is less than 1KB")
            End If

            ' Write request information to the file with HTML encoding.
            sw.WriteLine(Server.HtmlEncode(Request.RequestType))
            sw.WriteLine(Server.HtmlEncode(Request.UserHostAddress))
            sw.WriteLine(Server.HtmlEncode(Request.UserHostName))
            sw.WriteLine(Server.HtmlEncode(Request.HttpMethod))

            ' Iterate through the UserLanguages collection and
            ' write its HTML encoded values to the file.
            For langCount = 0 To Request.UserLanguages.Length
 - 1
                sw.WriteLine("User Language " &
 langCount.ToString() & _
                 ": " & Server.HtmlEncode( _
                     Request.UserLanguages(langCount)))
            Next

        Finally
            ' Close the stream to the file.
            sw.Close()
        End Try

        lblInfoSent.Text = _
         "Information about this request has been sent to a file."
    End Sub 'Page_Load



    Private Sub btnSendInfo_Click(sender As
 Object, e As System.EventArgs)
        lblInfoSent.Text = _
         "Hello, " & Server.HtmlEncode(txtBoxName.Text)
 & _
          ". You have created a new  request info file."
    End Sub 'btnSendInfo_Click

</script>
<html>
<head>
</head>
<body>
    <form runat="server">
        <p>
        </p>
        <p>
            Enter your hame here:
            <asp:TextBox id="txtBoxName" runat="server"></asp:TextBox>
        </p>
        <p>
            <asp:Button id="btnSendInfo" onclick="btnSendInfo_Click"
 runat="server" Text="Click Here"></asp:Button>
        </p>
        <p>
            <asp:Label id="lblInfoSent" runat="server"></asp:Label>
        </p>
    </form>
</body>
</html>
<%@ Page Language="C#" %>
<%@ import Namespace="System.Threading" %>
<%@ import Namespace="System.IO" %>
<script runat="server">

    /* NOTE: To use this sample, create a c:\temp\CS folder,
    *  add the ASP.NET account (in IIS 5.x <machinename>\ASPNET
,
    *  in IIS 6.x NETWORK SERVICE), and give it write permissions
    *  to the folder.*/

    private const string
 INFO_DIR = @"c:\temp\CS\RequestDetails";
    public static int requestCount;

    private void Page_Load(object sender, System.EventArgs
 e)
    {

        // Create a variable to use when iterating
        // through the UserLanguages property.
        int langCount;

        int requestNumber = Interlocked.Increment(ref requestCount);

        // Create the file to contain information about the request.
        string strFilePath = INFO_DIR + requestNumber.ToString()
 + @".txt";


        StreamWriter sw = File.CreateText(strFilePath);

        try
        {
            // Write request information to the file with HTML encoding.
            sw.WriteLine(Server.HtmlEncode(DateTime.Now.ToString()));
            sw.WriteLine(Server.HtmlEncode(Request.CurrentExecutionFilePath));
            sw.WriteLine(Server.HtmlEncode(Request.ApplicationPath));
            sw.WriteLine(Server.HtmlEncode(Request.FilePath));
            sw.WriteLine(Server.HtmlEncode(Request.Path));

            // Iterate through the Form collection and write
            // the values to the file with HTML encoding.
            // String[] formArray = Request.Form.AllKeys;
            foreach (string s in
 Request.Form)
            {
                sw.WriteLine("Form: " + Server.HtmlEncode(s));
            }

            // Write the PathInfo property value
            // or a string if it is empty.
            if (Request.PathInfo == String.Empty)
            {
                sw.WriteLine("The PathInfo property contains no information.");
            }
            else
            {
                sw.WriteLine(Server.HtmlEncode(Request.PathInfo));
            }

            // Write request information to the file with HTML encoding.
            sw.WriteLine(Server.HtmlEncode(Request.PhysicalApplicationPath));
            sw.WriteLine(Server.HtmlEncode(Request.PhysicalPath));
            sw.WriteLine(Server.HtmlEncode(Request.RawUrl));

            // Write a message to the file dependent upon
            // the value of the TotalBytes property.
            if (Request.TotalBytes > 1000)
            {
                sw.WriteLine("The request is 1KB or greater");
            }
            else
            {
                sw.WriteLine("The request is less than 1KB");
            }

            // Write request information to the file with HTML encoding.
            sw.WriteLine(Server.HtmlEncode(Request.RequestType));
            sw.WriteLine(Server.HtmlEncode(Request.UserHostAddress));
            sw.WriteLine(Server.HtmlEncode(Request.UserHostName));
            sw.WriteLine(Server.HtmlEncode(Request.HttpMethod));

            // Iterate through the UserLanguages collection and
            // write its HTML encoded values to the file.
            for (langCount=0; langCount < Request.UserLanguages.Length;
 langCount++)
            {
                sw.WriteLine(@"User Language " + langCount +": "
 + Server.HtmlEncode(Request.UserLanguages[langCount]));
            }
       }

       finally
       {
            // Close the stream to the file.
            sw.Close();
       }

        lblInfoSent.Text = "Information about this request
 has been sent to a file.";
    }


    private void btnSendInfo_Click(object sender,
 System.EventArgs e)
    {
        lblInfoSent.Text = "Hello, " + Server.HtmlEncode(txtBoxName.Text)
 +
          ". You have created a new  request info file.";
    }

</script>
<html>
<head>
</head>
<body>
    <form runat="server">
        <p>
        </p>
        <p>
            Enter your hame here:
            <asp:TextBox id="txtBoxName" runat="server"></asp:TextBox>
        </p>
        <p>
            <asp:Button id="btnSendInfo" onclick="btnSendInfo_Click"
 runat="server" Text="Click Here"></asp:Button>
        </p>
        <p>
            <asp:Label id="lblInfoSent" runat="server"></asp:Label>
        </p>
    </form>
</body>
</html>
.NET Framework のセキュリティ.NET Frameworkセキュリティ
継承階層継承階層
System.Object
  System.Web.HttpRequest
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

HttpRequest コンストラクタ

HttpRequest オブジェクト初期化します。

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

Public Sub New ( _
    filename As String, _
    url As String, _
    queryString As String _
)
Dim filename As String
Dim url As String
Dim queryString As String

Dim instance As New HttpRequest(filename,
 url, queryString)
public HttpRequest (
    string filename,
    string url,
    string queryString
)
public:
HttpRequest (
    String^ filename, 
    String^ url, 
    String^ queryString
)
public HttpRequest (
    String filename, 
    String url, 
    String queryString
)
public function HttpRequest (
    filename : String, 
    url : String, 
    queryString : String
)

パラメータ

filename

要求関連付けられたファイルの名前。

url

現在の要求URL に関する情報

queryString

要求と共に送信されるクエリ文字列全体 ('?' の後の部分すべて)。

解説解説

HttpRequest クラスインスタンス独自に作成する要はありません。HttpRequest クラスメソッドプロパティは、HttpApplication、HttpContext、PageUserControl の各クラスRequest プロパティによって公開されます。

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

HttpRequest プロパティ


パブリック プロパティパブリック プロパティ

  名前 説明
パブリック プロパティ AcceptTypes クライアントサポートされている MIME使用できる型の文字列配列取得します
パブリック プロパティ AnonymousID 存在する場合は、ユーザー匿名 ID取得します
パブリック プロパティ ApplicationPath サーバーASP.NET アプリケーション仮想アプリケーション ルート パス取得します
パブリック プロパティ AppRelativeCurrentExecutionFilePath アプリケーション ルート仮想パス取得しティルダ (~) 表記 ("~/page.aspx" など) を使用したアプリケーション ルート相対パスにします。
パブリック プロパティ Browser 要求実行中のクライアントブラウザ性能に関する情報取得または設定します
パブリック プロパティ ClientCertificate 現在、要求しているクライアントセキュリティ証明書取得します
パブリック プロパティ ContentEncoding エンティティ本体文字セット取得または設定します
パブリック プロパティ ContentLength クライアントから送信されコンテンツ長さバイト単位指定します
パブリック プロパティ ContentType 受信要求使用する MIMEContent-Type取得または設定します
パブリック プロパティ Cookies クライアントから送信されcookiesコレクション取得します
パブリック プロパティ CurrentExecutionFilePath 現在の要求仮想パス取得します
パブリック プロパティ FilePath 現在の要求仮想パス取得します
パブリック プロパティ Files マルチパート MIME 形式クライアントによってアップロードされたファイルコレクション取得します
パブリック プロパティ Filter 現在の入力ストリーム読み取るときに使用するフィルタ取得または設定します
パブリック プロパティ Form フォーム変数コレクション取得します
パブリック プロパティ Headers HTTP ヘッダーコレクション取得します
パブリック プロパティ HttpMethod クライアントによって使用される HTTP データ転送メソッド (GETPOSTHEAD など) を取得します
パブリック プロパティ InputStream 受信 HTTP エンティティ本体内容取得します
パブリック プロパティ IsAuthenticated 要求認証されているかどうかを示す値を取得します
パブリック プロパティ IsLocal 要求ローカル コンピュータから送信されたかどうかを示す値を取得します
パブリック プロパティ IsSecureConnection セキュリティ設定されソケットHTTP 接続使用しているどうか (つまり、HTTPS かどうか) を示す値を取得します
パブリック プロパティ Item CookiesForm、QueryString、ServerVariables の各コレクションから指定したオブジェクト取得します
パブリック プロパティ LogonUserIdentity 現在のユーザー対する WindowsIdentity の種類取得します
パブリック プロパティ Params QueryStringFormServerVariablesCookies の各項目が組み合わされコレクション取得します
パブリック プロパティ Path 現在の要求仮想パス取得します
パブリック プロパティ PathInfo URL 拡張子付きリソース追加パス情報取得します
パブリック プロパティ PhysicalApplicationPath 現在実行しているサーバー アプリケーションルート ディレクトリ物理ファイル システム パス取得します
パブリック プロパティ PhysicalPath 要求されURL一致する物理ファイル システム パス取得します
パブリック プロパティ QueryString HTTP クエリ文字列変数コレクション取得します
パブリック プロパティ RawUrl 現在の要求の生の URL取得します
パブリック プロパティ RequestType クライアントによって使用される HTTP データ転送メソッド (GET または POST) を取得または設定します
パブリック プロパティ ServerVariables Web サーバー変数コレクション取得します
パブリック プロパティ TotalBytes 現在の入力ストリームバイト数を取得します
パブリック プロパティ Url 現在の要求URL に関する情報取得します
パブリック プロパティ UrlReferrer 現在の URLリンクされている、クライアント前回要求した URL に関する情報取得します
パブリック プロパティ UserAgent クライアント ブラウザの生のユーザー エージェント文字列取得します
パブリック プロパティ UserHostAddress リモート クライアントIP ホスト アドレス取得します
パブリック プロパティ UserHostName リモート クライアントDNS 名を取得します
パブリック プロパティ UserLanguages クライアント言語設定並べ替えられた文字列配列取得します
参照参照

関連項目

HttpRequest クラス
System.Web 名前空間

HttpRequest メソッド


パブリック メソッドパブリック メソッド

( プロテクト メソッド参照)
  名前 説明
パブリック メソッド BinaryRead 現在の入力ストリームから、指定したバイト数のバイナリ読み取り実行します
パブリック メソッド Equals  オーバーロードされます2 つObject インスタンス等しかどうか判断します。 ( Object から継承されます。)
パブリック メソッド GetHashCode  特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用適してます。 ( Object から継承されます。)
パブリック メソッド GetType  現在のインスタンスType取得します。 ( Object から継承されます。)
パブリック メソッド MapImageCoordinates インカミング イメージ フィールド フォーム パラメータを、該当する x 座標値および y 座標値に割り当てます
パブリック メソッド MapPath オーバーロードされます要求されURL仮想パスを、現在の要求対すサーバー上の物理パス割り当てます
パブリック メソッド ReferenceEquals  指定した複数Object インスタンス同一かどうか判断します。 ( Object から継承されます。)
パブリック メソッド SaveAs HTTP 要求ディスク保存します
パブリック メソッド ToString  現在の Object を表す String返します。 ( Object から継承されます。)
パブリック メソッド ValidateInput CookiesForm、および QueryString の各プロパティ通じてアクセスするコレクションに対して検証実行します
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

HttpRequest クラス
System.Web 名前空間

HttpRequest メンバ

Web 要求中にクライアントから送信されHTTP 値を ASP.NET読み取ることができるようにします。

HttpRequest データ型公開されるメンバを以下の表に示します


パブリック コンストラクタパブリック コンストラクタ
  名前 説明
パブリック メソッド HttpRequest HttpRequest オブジェクト初期化します。
パブリック プロパティパブリック プロパティ
  名前 説明
パブリック プロパティ AcceptTypes クライアントサポートされている MIME使用できる型の文字列配列取得します
パブリック プロパティ AnonymousID 存在する場合は、ユーザー匿名 ID取得します
パブリック プロパティ ApplicationPath サーバーASP.NET アプリケーション仮想アプリケーション ルート パス取得します
パブリック プロパティ AppRelativeCurrentExecutionFilePath アプリケーション ルート仮想パス取得しティルダ (~) 表記 ("~/page.aspx" など) を使用したアプリケーション ルート相対パスにします。
パブリック プロパティ Browser 要求実行中のクライアントブラウザ性能に関する情報取得または設定します
パブリック プロパティ ClientCertificate 現在、要求しているクライアントセキュリティ証明書取得します
パブリック プロパティ ContentEncoding エンティティ本体文字セット取得または設定します
パブリック プロパティ ContentLength クライアントから送信されコンテンツ長さバイト単位指定します
パブリック プロパティ ContentType 受信要求使用する MIMEContent-Type取得または設定します
パブリック プロパティ Cookies クライアントから送信されcookiesコレクション取得します
パブリック プロパティ CurrentExecutionFilePath 現在の要求仮想パス取得します
パブリック プロパティ FilePath 現在の要求仮想パス取得します
パブリック プロパティ Files マルチパート MIME 形式クライアントによってアップロードされたファイルコレクション取得します
パブリック プロパティ Filter 現在の入力ストリーム読み取るときに使用するフィルタ取得または設定します
パブリック プロパティ Form フォーム変数コレクション取得します
パブリック プロパティ Headers HTTP ヘッダーコレクション取得します
パブリック プロパティ HttpMethod クライアントによって使用される HTTP データ転送メソッド (GETPOSTHEAD など) を取得します
パブリック プロパティ InputStream 受信 HTTP エンティティ本体内容取得します
パブリック プロパティ IsAuthenticated 要求認証されているかどうかを示す値を取得します
パブリック プロパティ IsLocal 要求ローカル コンピュータから送信されたかどうかを示す値を取得します
パブリック プロパティ IsSecureConnection セキュリティ設定されソケットHTTP 接続使用しているどうか (つまり、HTTPS かどうか) を示す値を取得します
パブリック プロパティ Item CookiesFormQueryString、ServerVariables の各コレクションから指定したオブジェクト取得します
パブリック プロパティ LogonUserIdentity 現在のユーザー対する WindowsIdentity の種類取得します
パブリック プロパティ Params QueryStringFormServerVariablesCookies の各項目が組み合わされコレクション取得します
パブリック プロパティ Path 現在の要求仮想パス取得します
パブリック プロパティ PathInfo URL 拡張子付きリソース追加パス情報取得します
パブリック プロパティ PhysicalApplicationPath 現在実行しているサーバー アプリケーションルート ディレクトリ物理ファイル システム パス取得します
パブリック プロパティ PhysicalPath 要求されURL一致する物理ファイル システム パス取得します
パブリック プロパティ QueryString HTTP クエリ文字列変数コレクション取得します
パブリック プロパティ RawUrl 現在の要求の生の URL取得します
パブリック プロパティ RequestType クライアントによって使用される HTTP データ転送メソッド (GET または POST) を取得または設定します
パブリック プロパティ ServerVariables Web サーバー変数コレクション取得します
パブリック プロパティ TotalBytes 現在の入力ストリームバイト数を取得します
パブリック プロパティ Url 現在の要求URL に関する情報取得します
パブリック プロパティ UrlReferrer 現在の URLリンクされている、クライアント前回要求した URL に関する情報取得します
パブリック プロパティ UserAgent クライアント ブラウザの生のユーザー エージェント文字列取得します
パブリック プロパティ UserHostAddress リモート クライアントIP ホスト アドレス取得します
パブリック プロパティ UserHostName リモート クライアントDNS 名を取得します
パブリック プロパティ UserLanguages クライアント言語設定並べ替えられた文字列配列取得します
パブリック メソッドパブリック メソッド
( プロテクト メソッド参照)
  名前 説明
パブリック メソッド BinaryRead 現在の入力ストリームから、指定したバイト数のバイナリ読み取り実行します
パブリック メソッド Equals  オーバーロードされます2 つObject インスタンス等しかどうか判断します。 (Object から継承されます。)
パブリック メソッド GetHashCode  特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用適してます。 (Object から継承されます。)
パブリック メソッド GetType  現在のインスタンスType取得します。 (Object から継承されます。)
パブリック メソッド MapImageCoordinates インカミング イメージ フィールド フォーム パラメータを、該当する x 座標値および y 座標値に割り当てます
パブリック メソッド MapPath オーバーロードされます要求されURL仮想パスを、現在の要求対すサーバー上の物理パス割り当てます
パブリック メソッド ReferenceEquals  指定した複数Object インスタンス同一かどうか判断します。 (Object から継承されます。)
パブリック メソッド SaveAs HTTP 要求ディスク保存します
パブリック メソッド ToString  現在の Object を表す String返します。 (Object から継承されます。)
パブリック メソッド ValidateInput CookiesForm、および QueryString の各プロパティ通じてアクセスするコレクションに対して検証実行します
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

HttpRequest クラス
System.Web 名前空間


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

辞書ショートカット

すべての辞書の索引

「HttpRequest」の関連用語

HttpRequestのお隣キーワード
検索ランキング

   

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



HttpRequestのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
PHP Documentation GroupPHP Documentation Group
Copyright © 1997 - 2024 by the PHP Documentation Group.
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2024 Microsoft.All rights reserved.

©2024 GRAS Group, Inc.RSS