(C#) Transition from Http.GetHead to Http.HttpNoBody
Provides instructions for replacing deprecated GetHead method calls with HttpNoBody. Note: This example requires Chilkat v11.0.0 or greater.
Chilkat.Http http = new Chilkat.Http();
string url = "https://www.example.com/";
// ------------------------------------------------------------------------
// The GetHead method is deprecated:
Chilkat.HttpResponse resp1 = http.GetHead(url);
if (http.LastMethodSuccess == false) {
Debug.WriteLine(http.LastErrorText);
return;
}
Debug.WriteLine(Convert.ToString(resp1.StatusCode));
// ------------------------------------------------------------------------
// Do the equivalent using HttpNoBody.
// Your application creates a new, empty response object which is passed
// in the last argument and filled with the HTTP response upon success.
Chilkat.HttpResponse resp2 = new Chilkat.HttpResponse();
bool success = http.HttpNoBody("HEAD",url,resp2);
if (success == false) {
Debug.WriteLine(http.LastErrorText);
return;
}
Debug.WriteLine(Convert.ToString(resp2.StatusCode));
|