ServerProtocolViolation错误错误、ServerProtocolViolation

2023-09-06 09:06:08 作者:迷茫丶对白

我打了以下code服务器和我遇到一个ServerProtocolViolation错误:

I am hitting up a server with the following code and am encountering a ServerProtocolViolation error:

// Prepare the webpage
HttpWebRequest request = (HttpWebRequest) WebRequest.Create(url + queryString);

// execute the request
HttpWebResponse response = (HttpWebResponse)request.GetResponse();

有谁知道如何解决这种错误?

Does anyone know how to work around this kind of error?

推荐答案

这个错误意味着你发送请求的Web服务器上不符合HTTP标准。

This error means that the webserver that you're sending the request to isn't conforming to the HTTP standard.

除了固定的服务器或重写的HttpWebRequest 来获得更丰厚的,没有什么可以做。

Other than fixing the server or rewriting HttpWebRequest to be more generous, there isn't much you can do.

您需要什么网址,以及有什么异常的文字?

What URL are you requesting, and what's the text of the exception?

修改:如果您要求在提琴手中的网址,你会看到服务器未返回任何头。您应该联系服务器的所有者和抱怨。

EDIT: If you request the URL in Fiddler, you'll see that the server didn't return any headers. You should contact the owner of the server and complain.

作为一种解决方法,如果您运行的提琴手发送请求,提琴手将修复的响应,并允许HttpWebResponse解析它。

As a workaround, if you run Fiddler while sending the request, Fiddler will fix the response and allow HttpWebResponse to parse it.

 
精彩推荐