![]() |
Chilkat HOME Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi DLL Go Java Node.js Objective-C PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(Unicode C++) HTTP Response InspectionSee more HTTP ExamplesDemonstrates how to inspect the HTTP response, including the status code, status text, and response headers, for Chilkat methods that don't use anHttpResponse object.
#include <CkHttpW.h> #include <CkMimeW.h> void ChilkatSample(void) { CkHttpW http; // Returns the contents of the response body. const wchar_t *jsonText = http.quickGetStr(L"https://chilkatsoft.com/helloWorld.json"); // Examine the response status code. wprintf(L"response status code: %d\n",http.get_LastStatus()); // Examine the response status text wprintf(L"response status text: %s\n",http.lastStatusText()); // Examine the full response header. wprintf(L"response header:\n"); wprintf(L"%s\n",http.lastResponseHeader()); wprintf(L"----\n"); // Examine the response content-type wprintf(L"LastContentType = %s\n",http.lastContentType()); // Examine the response last-mod date wprintf(L"LastModDate = %s\n",http.lastModDate()); // Load the response header into a Chilkat MIME object to access its fields individually. CkMimeW mime; mime.LoadMime(http.lastResponseHeader()); int numHeaders = mime.get_NumHeaderFields(); int i = 0; wprintf(L"---- MIME Headers ----\n"); while (i < numHeaders) { wprintf(L"name: %s\n",mime.getHeaderFieldName(i)); wprintf(L"value: %s\n",mime.getHeaderFieldValue(i)); i = i + 1; } wprintf(L"----\n"); // Get a header field value by name: wprintf(L"ETag: %s\n",mime.getHeaderField(L"ETag")); // Output: // response status code: 200 // response status text: OK // response header: // Content-Type: application/json // Last-Modified: Sun, 20 Aug 2023 11:36:27 GMT // Accept-Ranges: bytes // ETag: "34c27f8e5ad3d91:0" // Server: Microsoft-IIS/10.0 // X-Powered-By: ASP.NET // Date: Sat, 30 Aug 2025 14:38:13 GMT // Content-Length: 22 // ---- // LastContentType = application/json // LastModDate = 2023-08-20 // ---- MIME Headers ---- // name: Content-Type // value: application/json // name: Last-Modified // value: Sun, 20 Aug 2023 11:36:27 GMT // name: Accept-Ranges // value: bytes // name: ETag // value: "34c27f8e5ad3d91:0" // name: Server // value: Microsoft-IIS/10.0 // name: X-Powered-By // value: ASP.NET // name: Date // value: Sat, 30 Aug 2025 14:38:13 GMT // name: Content-Length // value: 22 // ---- // ETag: "34c27f8e5ad3d91:0" } |
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.