C# PrestashopWeb服务http头返回什么
我正在开发一个使用prestashop web服务的类。C# PrestashopWeb服务http头返回什么,c#,web-services,httpwebrequest,prestashop,httpwebresponse,C#,Web Services,Httpwebrequest,Prestashop,Httpwebresponse,我正在开发一个使用prestashop web服务的类。 我现在遇到了一个问题,因为我不知道从prestashop Web服务返回的HEAD请求实际是什么… 这是我的代码: #region HEAD public string Head() { string requestURL = WebServiceURL + "/" + Table + "/" + TableID; WebRequest wr = WebRequest.Create(requestURL); wr.
我现在遇到了一个问题,因为我不知道从prestashop Web服务返回的HEAD请求实际是什么…
这是我的代码:
#region HEAD
public string Head() {
string requestURL = WebServiceURL + "/" + Table + "/" + TableID;
WebRequest wr = WebRequest.Create(requestURL);
wr.Method = "HEAD";
wr.ContentType = "application/xml";
wr.Credentials = new NetworkCredential(UserName, PassWord);
try {
HttpWebResponse response = (HttpWebResponse) wr.GetResponse();
return response.Headers.ToString();
}catch(Exception) { return ""; }
}
#endregion
返回此文件:
Vary: Host
Access-Time: 1391506047
PSWS-Version: 1.5.6.1
Execution-Time: 0.011
Content-Sha1: ...
Content-Type: text/xml;charset=utf-8
Date: Tue, 04 Feb 2014 09:27:26 GMT
Set-Cookie: ....; httponly
Server: Apache/2.4.3 (Win32) OpenSSL/1.0.1c PHP/5.4.7
X-Powered-By: PrestaShop Webservice
现在我的问题是,这是否是从prestashop Web服务获取头部数据的正确方法,以及该数据是否正确?
Thx:)数据看起来正常
我不会在代码中使用Content-Type
header,因为HEAD类似于GET,即使在响应中也不会在请求中发送消息体,只有header数据被提交回客户端
检查。您需要HEAD请求做什么?