I have a C # console application (.NET 2.0 framework) that is executing an HTTP message using the following code:
StringBuilder postData = new StringBuilder(100);
postData.Append("post.php?");
postData.Append("Key1=");
postData.Append(val1);
postData.Append("&Key2=");
postData.Append(val2);
byte[] dataArray = Encoding.UTF8.GetBytes(postData.ToString());
HttpWebRequest httpRequest = (HttpWebRequest)WebRequest.Create("http://example.com/");
httpRequest.Method = "POST";
httpRequest.ContentType = "application/x-www-form-urlencoded";
httpRequest.ContentLength = dataArray.Length;
Stream requestStream = httpRequest.GetRequestStream();
requestStream.Write(dataArray, 0, dataArray.Length);
requestStream.Flush();
requestStream.Close();
HttpWebResponse webResponse = (HttpWebResponse)httpRequest.GetResponse();
if (httpRequest.HaveResponse == true) {
Stream responseStream = webResponse.GetResponseStream();
StreamReader responseReader = new System.IO.StreamReader(responseStream, Encoding.UTF8);
String responseString = responseReader.ReadToEnd();
}
Outputs from this:
webResponse.ContentLength = -1
webResponse.ContentType = text / html
webResponse.ContentEncoding is empty.
ReplyString is HTML with a header and body.
However, if I put the same URL in the browser ( http://example.com/post.php?Key1=some_value&Key2=some_other_value ), I get a small XML fragment, for example:
<?xml version="1.0" ?>
<RESPONSE RESULT="SUCCESS"/>
HTML-, . ? , HTML. ? , .