![]() |
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
(Delphi DLL) 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.
uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Mime, Http; ... procedure TForm1.Button1Click(Sender: TObject); var http: HCkHttp; jsonText: PWideChar; mime: HCkMime; numHeaders: Integer; i: Integer; begin http := CkHttp_Create(); // Returns the contents of the response body. jsonText := CkHttp__quickGetStr(http,'https://chilkatsoft.com/helloWorld.json'); // Examine the response status code. Memo1.Lines.Add('response status code: ' + IntToStr(CkHttp_getLastStatus(http))); // Examine the response status text Memo1.Lines.Add('response status text: ' + CkHttp__lastStatusText(http)); // Examine the full response header. Memo1.Lines.Add('response header:'); Memo1.Lines.Add(CkHttp__lastResponseHeader(http)); Memo1.Lines.Add('----'); // Examine the response content-type Memo1.Lines.Add('LastContentType = ' + CkHttp__lastContentType(http)); // Examine the response last-mod date Memo1.Lines.Add('LastModDate = ' + CkHttp__lastModDate(http)); // Load the response header into a Chilkat MIME object to access its fields individually. mime := CkMime_Create(); CkMime_LoadMime(mime,CkHttp__lastResponseHeader(http)); numHeaders := CkMime_getNumHeaderFields(mime); i := 0; Memo1.Lines.Add('---- MIME Headers ----'); while i < numHeaders do begin Memo1.Lines.Add('name: ' + CkMime__getHeaderFieldName(mime,i)); Memo1.Lines.Add('value: ' + CkMime__getHeaderFieldValue(mime,i)); i := i + 1; end; Memo1.Lines.Add('----'); // Get a header field value by name: Memo1.Lines.Add('ETag: ' + CkMime__getHeaderField(mime,'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" CkHttp_Dispose(http); CkMime_Dispose(mime); end; |
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.