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

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

HttpWebRequest.SendChunked プロパティ

インターネット リソースセグメント単位データ送信するかどうかを示す値を取得または設定します

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

Dim instance As HttpWebRequest
Dim value As Boolean

value = instance.SendChunked

instance.SendChunked = value
public bool SendChunked { get;
 set; }
public:
property bool SendChunked {
    bool get ();
    void set (bool value);
}
/** @property */
public boolean get_SendChunked ()

/** @property */
public void set_SendChunked (boolean value)

プロパティ
インターネット リソースセグメント単位データ送信する場合trueそれ以外場合false既定値false です。

例外例外
例外種類条件

InvalidOperationException

要求が GetRequestStream、BeginGetRequestStream、GetResponse、または BeginGetResponse の各メソッド呼び出しによって開始されました。

解説解説

SendChunkedtrue場合要求セグメント単位インターネット リソースデータ送信しますインターネット リソースは、チャンク データ受信サポートしている必要があります

GetRequestStreamBeginGetRequestStreamGetResponse、または BeginGetResponse の各メソッド呼び出しによって開始した要求の後に SendChunked プロパティ変更すると、InvalidOperationExceptionスローさます。

使用例使用例

SendChunked プロパティtrue設定してインターネット リソースデータセグメント単位送信するコード例次に示します

' A new 'HttpWebRequest' object is created.
Dim myHttpWebRequest As HttpWebRequest = CType(WebRequest.Create(myUri),
 HttpWebRequest)
myHttpWebRequest.SendChunked = True
' 'TransferEncoding' property is set to 'gzip'.
myHttpWebRequest.TransferEncoding = "gzip"
Console.WriteLine(ControlChars.Cr + "Please Enter the data to
 be posted to the (http://" + ChrW(60) + "machine
 name" + ChrW(62) + "/CodeSnippetTest.asp) uri:")
Dim inputData As String
 = Console.ReadLine()
Dim postData As String =
 "testdata" + ChrW(61) + inputData
' 'Method' property of 'HttpWebRequest' class is set to POST.
myHttpWebRequest.Method = "POST"
Dim encodedData As New ASCIIEncoding()
Dim byteArray As Byte()
 = encodedData.GetBytes(postData)
' 'ContentType' property of the 'HttpWebRequest' class is set to "application/x-www-form-urlencoded".
myHttpWebRequest.ContentType = "application/x-www-form-urlencoded"
' 'ContentLength' property is set to Length of the data to be posted.
myHttpWebRequest.ContentLength = byteArray.Length
Dim newStream As Stream = myHttpWebRequest.GetRequestStream()
newStream.Write(byteArray, 0, byteArray.Length)
newStream.Close()
Console.WriteLine(ControlChars.Cr + "Data has been posted to the
 Uri" + ControlChars.Cr + ControlChars.Cr + "Please
 wait for the response..........")
' The response object of 'HttpWebRequest' is assigned to a 'HttpWebResponse'
 variable.
Dim myHttpWebResponse As HttpWebResponse =
 CType(myHttpWebRequest.GetResponse(), HttpWebResponse)
' Displaying the contents of the page to the console
Dim streamResponse As Stream = myHttpWebResponse.GetResponseStream()
Dim streamRead As New StreamReader(streamResponse)
Dim readBuff(256) As [Char]
Dim count As Integer = streamRead.Read(readBuff,
 0, 256)
Console.WriteLine(ControlChars.Cr + "The contents of the HTML
 page are :  ")
While count > 0
    Dim outputData As New
 [String](readBuff, 0, count)
    Console.WriteLine(outputData)
    count = streamRead.Read(readBuff, 0, 256)
End While
' Release the response object resources.  
streamRead.Close()
streamResponse.Close()
myHttpWebResponse.Close()
// A new 'HttpWebRequest' object is created.
HttpWebRequest myHttpWebRequest=(HttpWebRequest)WebRequest.Create(myUri);
myHttpWebRequest.SendChunked=true;
// 'TransferEncoding' property is set to 'gzip'.
myHttpWebRequest.TransferEncoding="gzip";
Console.WriteLine("\nPlease Enter the data to be posted to the (http://<machine
 name>/CodeSnippetTest.asp) uri:");
string inputData =Console.ReadLine();
string postData="testdata="+inputData;
// 'Method' property of 'HttpWebRequest' class is set to POST.
myHttpWebRequest.Method="POST";
ASCIIEncoding encodedData=new ASCIIEncoding();
byte[]  byteArray=encodedData.GetBytes(postData);
// 'ContentType' property of the 'HttpWebRequest' class is set to "application/x-www-form-urlencoded".
myHttpWebRequest.ContentType="application/x-www-form-urlencoded";
// 'ContentLength' property is set to Length of the data to be posted.
myHttpWebRequest.ContentLength=byteArray.Length;
Stream newStream=myHttpWebRequest.GetRequestStream();
newStream.Write(byteArray,0,byteArray.Length);
newStream.Close();
Console.WriteLine("\nData has been posted to the Uri\n\nPlease wait for
 the response..........");
// The response object of 'HttpWebRequest' is assigned to a 'HttpWebResponse'
 variable.
HttpWebResponse myHttpWebResponse=(HttpWebResponse)myHttpWebRequest.GetResponse();
// Displaying the contents of the page to the console
Stream streamResponse=myHttpWebResponse.GetResponseStream();
StreamReader streamRead = new StreamReader( streamResponse );
Char[] readBuff = new Char[256];
int count = streamRead.Read( readBuff, 0, 256 );
Console.WriteLine("\nThe contents of the HTML page are :  ");
while (count > 0) 
{
   String outputData = new String(readBuff, 0, count);
   Console.WriteLine(outputData);
   count = streamRead.Read(readBuff, 0, 256);
}
// Release the response object resources.
streamRead.Close();
streamResponse.Close();
myHttpWebResponse.Close(); 
// A new 'HttpWebRequest' object is created.
HttpWebRequest^ myHttpWebRequest = (HttpWebRequest^)( WebRequest::Create( myUri )
 );
myHttpWebRequest->SendChunked = true;
// 'TransferEncoding' property is set to 'gzip'.
myHttpWebRequest->TransferEncoding = "gzip";
Console::WriteLine( "\nPlease Enter the data to be posted to the (http://<machine
 name>/CodeSnippetTest::asp) uri:" );
String^ inputData = Console::ReadLine();
String^ postData = String::Concat( "testdata= ", inputData );
// 'Method' property of 'HttpWebRequest' class is set to POST.
myHttpWebRequest->Method = "POST";
ASCIIEncoding^ encodedData = gcnew ASCIIEncoding;
array<Byte>^ byteArray = encodedData->GetBytes( postData );
// 'ContentType' property of the 'HttpWebRequest' class is set to S"application/x-www-form-urlencoded".
myHttpWebRequest->ContentType = "application/x-www-form-urlencoded";
// 'ContentLength' property is set to Length of the data to be posted.
myHttpWebRequest->ContentLength = byteArray->Length;
Stream^ newStream = myHttpWebRequest->GetRequestStream();
newStream->Write( byteArray, 0, byteArray->Length );
newStream->Close();
Console::WriteLine( "\nData has been posted to the Uri\n\nPlease wait for
 the response.........." );
// The response object of 'HttpWebRequest' is assigned to a 'HttpWebResponse'
 variable.
HttpWebResponse^ myHttpWebResponse = (HttpWebResponse^)( myHttpWebRequest->GetResponse()
 );
// Displaying the contents of the page to the console
Stream^ streamResponse = myHttpWebResponse->GetResponseStream();
StreamReader^ streamRead = gcnew StreamReader( streamResponse );
array<Char>^ readBuff = gcnew array<Char>(256);
int count = streamRead->Read( readBuff, 0, 256 );
Console::WriteLine( "\nThe contents of the HTML page are :  " );
while ( count > 0 )
{
   String^ outputData = gcnew String( readBuff,0,count );
   Console::WriteLine( outputData );
   count = streamRead->Read( readBuff, 0, 256 );
}
streamRead->Close();
streamResponse->Close();
myHttpWebResponse->Close();
// A new 'HttpWebRequest' object is created.
HttpWebRequest myHttpWebRequest = (HttpWebRequest)
    WebRequest.Create(myUri);
myHttpWebRequest.set_SendChunked(true);
// 'TransferEncoding' property is set to 'gzip'.
myHttpWebRequest.set_TransferEncoding("gzip");
Console.WriteLine("\nPlease Enter the data to "
    + " be posted to the "
    + "(http://<machine name>/CodeSnippetTest.asp) uri:");
String inputData = Console.ReadLine();
String postData = "testdata=" + inputData;

// 'Method' property of 'HttpWebRequest' class is set to POST.
myHttpWebRequest.set_Method("POST");
ASCIIEncoding encodedData = new ASCIIEncoding();
ubyte byteArray[] = encodedData.GetBytes(postData);

// 'ContentType' property of the 'HttpWebRequest' class is set
// to "application/x-www-form-urlencoded".
myHttpWebRequest.set_ContentType
    ("application/x-www-form-urlencoded");

// 'ContentLength' property is set to Length of the data to 
// be posted.
myHttpWebRequest.set_ContentLength(byteArray.length);
Stream newStream = myHttpWebRequest.GetRequestStream();
newStream.Write(byteArray, 0, byteArray.length);
newStream.Close();
Console.WriteLine("\nData has been posted to the Uri\n\nPlease"
    +" wait for the response..........");
// The response object of 'HttpWebRequest' is assigned to a 
//'HttpWebResponse' variable.
HttpWebResponse myHttpWebResponse = (HttpWebResponse)
    myHttpWebRequest.GetResponse();
// Displaying the contents of the page to the console
Stream streamResponse = myHttpWebResponse.GetResponseStream();
StreamReader streamRead = new StreamReader(streamResponse);
char readBuff[] = new char[256];
int count = streamRead.Read(readBuff, 0, 256);

Console.WriteLine("\nThe contents of the HTML page are :  ");
while (count > 0) {
    String outputData = new String(readBuff, 0, count);
    Console.WriteLine(outputData);
    count = streamRead.Read(readBuff, 0, 256);
}

// Release the response object resources.
streamRead.Close();
streamResponse.Close();
myHttpWebResponse.Close();
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



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

辞書ショートカット

すべての辞書の索引

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

   

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



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

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

©2024 GRAS Group, Inc.RSS