G
Guest
I have a strange behavior of a following code:
HttpWebRequest
request=(HttpWebRequest)WebRequest.Create(@"http://.../target.jsp");
request.ProtocolVersion=HttpVersion.Version11;
request.Method="POST";
request.ContentType="text/plain";
request.KeepAlive = true;
request.ContentLength=data.Length;
try
{
Stream newStream=request.GetRequestStream();
newStream.Write(data,0,data.Length);
newStream.Close();
HttpWebResponse response=(HttpWebResponse)request.GetResponse();
//Exception here
...
}
catch
{
}
After GetResponse is called I receive exception with Status =
WebExceptionStatus.ServerProtocolViolation.
I used sniffer to scan which requests/reponses are being handled during this
operation from IE and from my code - all of requests/responses are the
same - response is HTTP 200 OK for both ways of request.
Does anybody can shed a light why .Net Framework returns such an exception
even if response status is OK?
HttpWebRequest
request=(HttpWebRequest)WebRequest.Create(@"http://.../target.jsp");
request.ProtocolVersion=HttpVersion.Version11;
request.Method="POST";
request.ContentType="text/plain";
request.KeepAlive = true;
request.ContentLength=data.Length;
try
{
Stream newStream=request.GetRequestStream();
newStream.Write(data,0,data.Length);
newStream.Close();
HttpWebResponse response=(HttpWebResponse)request.GetResponse();
//Exception here
...
}
catch
{
}
After GetResponse is called I receive exception with Status =
WebExceptionStatus.ServerProtocolViolation.
I used sniffer to scan which requests/reponses are being handled during this
operation from IE and from my code - all of requests/responses are the
same - response is HTTP 200 OK for both ways of request.
Does anybody can shed a light why .Net Framework returns such an exception
even if response status is OK?