Hi,
msdn give's us this example to retrieve the post data.
public static void ShowRequestData (HttpListenerRequest request)
{
if (!request.HasEntityBody)
{
Console.WriteLine("No client data was sent with the request.");
return;
}
System.IO.Stream body = request.InputStream;
System.Text.Encoding encoding = request.ContentEncoding;
System.IO.StreamReader reader = new System.IO.StreamReader(body, encoding);
if (request.ContentType != null)
{
Console.WriteLine("Client data content type {0}", request.ContentType);
}
Console.WriteLine("Client data content length {0}", request.ContentLength64);
Console.WriteLine("Start of client data:");
// Convert the data to a string and display it on the console.
string s = reader.ReadToEnd();
Console.WriteLine(s);
Console.WriteLine("End of client data:");
body.Close();
reader.Close();
// If you are finished with the request, it should be closed also.
}
I checked the Streamreader class and there are no Begin... End... methods. Does this mean the Post data can not be retrieved asynchronously? Or has it already been retrieved before the callback from the HttpListener came?
I would not like to get a thread-stall while a chunk of slow post data comes in.
What is the correct asynchronous way to do this? (or is the ReadToEnd in fact correct?)
thanks
R