HttpWebRequest.GetResponse () error for empty response header

I am making a fairly simple service call using

HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create(PagePath);
{
    //Setting parameters
}

Everything seems beautiful. But when I call

HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse();

I get scary

"Server committed protocol violation. Section = ResponseStatusLine."

But in this case, the reason is obvious, the solution is not!

The server does not return response headers, even HTTP / 1.0 200 OK.

This, apparently, causes the net net code to fail with a Null reference exception, which then translates into a "protocol violation" error.

Is it possible to get around the header check altogether. Unfortunately, this does not prevent this error if there are no headers.

Thanks in advance.

+4
source share

Source: https://habr.com/ru/post/1618851/


All Articles