Reputation: 625
I'm developing a class that operates with the prestashop web service.
And I have a problem now because I don't know what a HEAD request actually gets back from prestashop webservice...
This is my code:
#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
which return this:
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
Now my question is, if this is the correct way of getting the HEAD data from the prestashop webservice and if this data is right?
Thx :)
Upvotes: 1
Views: 948
Reputation: 766
Data looks OK.
I wouldn't use Content-Type
header in your code, because HEAD is similar to GET and sends no message body in a request even in a response, only the header data is submitted back to the client.
Check HTTP Method Definitions.
Upvotes: 1