---
product: Chilkat
product_version: 11.7.0
language: pascal
language_label: Lazarus Pascal
class: HttpResponse
license: bundle
deprecated: false
reference_html: https://www.chilkatsoft.com/refdoc/pascal_HttpResponseRef.html
---
# Chilkat HttpResponse — Lazarus Pascal — v11.7.0

> Chilkat 11.7.0 · language=pascal · class=HttpResponse
> Other versions: replace `11.7.0` in this URL. Other languages: `https://www.chilkatsoft.com/ai-docs/v/11.7.0/<lang>/classes/HttpResponse.md`.
> Language-wide rules (install, unlock, error model, strings/bytes): `https://www.chilkatsoft.com/ai-docs/v/11.7.0/pascal/guide.md`.

## Purpose

**Inspect HTTP status, headers, cookies, redirects, and response bodies.**

`Chilkat.HttpResponse` represents an HTTP response returned by certain `Chilkat.Http` methods. It provides access to the response status line, status code, headers, cookies, charset, content length, body bytes, body text, full MIME response, redirect URL, and helper methods for saving or loading the response body into Chilkat objects such as `BinData`, `StringBuilder`, `JsonObject`, `JsonArray`, and `Xml`.

**Status and reason**

Read the HTTP status code, status line, and related response information to determine whether the request succeeded, redirected, or failed.

**Headers and cookies**

Inspect response headers, retrieve individual header values, and access cookies returned by the server.

**Body as text or bytes**

Get the response body as raw bytes or decoded text, using the response charset information when appropriate.

**Structured body loading**

Load the body directly into `JsonObject`, `JsonArray`, `Xml`, `BinData`, or `StringBuilder` objects for further processing.

**Redirect information**

Access redirect-related information such as the redirect URL when the server responds with a redirect status.

**Save and inspect responses**

Save body content, inspect the full MIME-style response, and use response metadata for diagnostics, logging, or API troubleshooting.

**Common pattern:** Send a request with `Chilkat.Http`, check the `StatusCode`, inspect headers or cookies as needed, then retrieve the body in the form best suited to the response content: text, bytes, `BinData`, `StringBuilder`, JSON, or XML. Use `HttpResponse` for response inspection; use `Chilkat.Http` for the actual network request.

For an extended overview, see [HttpResponse Class Overview](https://www.chilkatsoft.com/httpresponse_class_overview.asp).

## Object creation, unlocking and error handling

**Create / Free**

```pascal
uses
  Chilkat.HttpResponse;

var
  obj: THttpResponse;
begin
  obj := THttpResponse.Create;
  try
    if not obj.IsValid then
      raise Exception.Create('Failed to create a THttpResponse instance.');

    // ... use obj ...

  finally
    obj.Free;
  end;
end;
```

`constructor Create;`

Allocates the underlying CkHttpResponse object and returns a new THttpResponse instance. Simply adding **Chilkat.HttpResponse** to the unit's `uses` clause is enough to locate and bind to the Chilkat shared library (DLL / .so / .dylib) at runtime — no separate load step is required. Check `obj.IsValid` after calling `Create`; it is `False` if the underlying library could not be found/loaded or the object could not be allocated (for example, when unlicensed).

`destructor Destroy; override;`

Every THttpResponse created by calling `Create` should eventually be released by calling `.Free` (inherited from `TObject`). The destructor automatically disposes the underlying CkHttpResponse handle. A native (unmanaged) memory leak occurs if the object is never freed.

Call `Global.UnlockBundle` once at the start of the program, before using this or any other Chilkat class. Any string unlocks a fully functional 30-day trial; a purchased unlock code is used in production. See `guide.md` for the exact code in Lazarus Pascal.

## Members common to every Chilkat class

Documented once per language in `common-members.md`; listed here so this page is self-contained.

| Property | Signature | Access | Meaning |
|---|---|---|---|
| `DebugLogFilePath` | `property DebugLogFilePath: string read GetDebugLogFilePath write SetDebugLogFilePath;` | read/write | If set to a file path, this property logs the LastErrorText of each Chilkat method or property call to the specified file. |
| `LastErrorHtml` | `property LastErrorHtml: string read GetLastErrorHtml;` | read-only | Provides HTML-formatted information about the last called method or property. |
| `LastErrorText` | `property LastErrorText: string read GetLastErrorText;` | read-only | Provides plain text information about the last called method or property. |
| `LastErrorXml` | `property LastErrorXml: string read GetLastErrorXml;` | read-only | Provides XML-formatted information about the last called method or property. |
| `LastMethodSuccess` | `property LastMethodSuccess: Boolean read GetLastMethodSuccess write SetLastMethodSuccess;` | read/write | Indicates the success or failure of the most recent method call: `True` means success, `False` means failure. |
| `VerboseLogging` | `property VerboseLogging: Boolean read GetVerboseLogging write SetVerboseLogging;` | read/write | If set to `True`, then the contents of LastErrorText (or LastErrorXml, or LastErrorHtml) may contain more verbose information. |
| `Version` | `property Version: string read GetVersion;` | read-only | Version of the component/library, such as "10.1.0" |

## Member index

| Member | Kind | Signature |
|---|---|---|
| `BodyQP` | property, read-only | `property BodyQP: string read GetBodyQP;` |
| `BodyStr` | property, read-only | `property BodyStr: string read GetBodyStr;` |
| `Charset` | property, read-only | `property Charset: string read GetCharset;` |
| `ContentLength` | property, read-only | `property ContentLength: LongWord read GetContentLength;` |
| `ContentLength64` | property, read-only | `property ContentLength64: Int64 read GetContentLength64;` |
| `DateStr` | property, read-only | `property DateStr: string read GetDateStr;` |
| `Domain` | property, read-only | `property Domain: string read GetDomain;` |
| `FinalRedirectUrl` | property, read-only | `property FinalRedirectUrl: string read GetFinalRedirectUrl;` |
| `FullMime` | property, read-only | `property FullMime: string read GetFullMime;` |
| `Header` | property, read-only | `property Header: string read GetHeader;` |
| `NumCookies` | property, read-only | `property NumCookies: Integer read GetNumCookies;` |
| `NumHeaderFields` | property, read-only | `property NumHeaderFields: Integer read GetNumHeaderFields;` |
| `StatusCode` | property, read-only | `property StatusCode: Integer read GetStatusCode;` |
| `StatusLine` | property, read-only | `property StatusLine: string read GetStatusLine;` |
| `StatusText` | property, read-only | `property StatusText: string read GetStatusText;` |
| `UncommonOptions` | property, read/write | `property UncommonOptions: string read GetUncommonOptions write SetUncommonOptions;` |
| `GetBodyBd` | method | `// binData is a TBinData object. function GetBodyBd(binData: TChilkatBase): Boolean;` |
| `GetBodyJarr` | method | `// jarr is a TJsonArray object. function GetBodyJarr(jarr: TChilkatBase): Boolean;` |
| `GetBodyJson` | method | `// json is a TJsonObject object. function GetBodyJson(json: TChilkatBase): Boolean;` |
| `GetBodySb` | method | `// sb is a TStringBuilder object. function GetBodySb(sb: TChilkatBase): Boolean;` |
| `GetBodyXml` | method | `// xml is a TXml object. function GetBodyXml(xml: TChilkatBase): Boolean;` |
| `GetCookieDomain` | method | `function GetCookieDomain(index: Integer): string;` |
| `GetCookieExpiresStr` | method | `function GetCookieExpiresStr(index: Integer): string;` |
| `GetCookieName` | method | `function GetCookieName(index: Integer): string;` |
| `GetCookiePath` | method | `function GetCookiePath(index: Integer): string;` |
| `GetCookieValue` | method | `function GetCookieValue(index: Integer): string;` |
| `GetHeaderField` | method | `function GetHeaderField(const fieldName: string): string;` |
| `GetHeaderFieldAttr` | method | `function GetHeaderFieldAttr(const fieldName: string;     const attrName: string): string;` |
| `GetHeaderName` | method | `function GetHeaderName(index: Integer): string;` |
| `GetHeaderValue` | method | `function GetHeaderValue(index: Integer): string;` |
| `LoadTaskResult` | method | `// task is a TTask object. function LoadTaskResult(task: TChilkatBase): Boolean;` |
| `SaveBodyBinary` | method | `function SaveBodyBinary(const path: string): Boolean;` |
| `SaveBodyText` | method | `function SaveBodyText(bCrlf: Boolean;     const path: string): Boolean;` |
| `UrlEncParamValue` | method | `function UrlEncParamValue(const encodedParamString: string;     const paramName: string): string;` |

## Properties

### HttpResponse.BodyQP

`Chilkat 11.7.0 · pascal · HttpResponse · BodyQP · property · read-only`

```pascal
property BodyQP: string read GetBodyQP;
```

The same as the Body property, but returned as a quoted-printable encoded string.

### HttpResponse.BodyStr

`Chilkat 11.7.0 · pascal · HttpResponse · BodyStr · property · read-only`

```pascal
property BodyStr: string read GetBodyStr;
```

The response body returned as a string.

### HttpResponse.Charset

`Chilkat 11.7.0 · pascal · HttpResponse · Charset · property · read-only`

```pascal
property Charset: string read GetCharset;
```

The response charset, such as `iso-8859-1`, if applicable. Obviously, responses for GIF and JPG files will not have a charset.

### HttpResponse.ContentLength

`Chilkat 11.7.0 · pascal · HttpResponse · ContentLength · property · read-only`

```pascal
property ContentLength: LongWord read GetContentLength;
```

The content length of the response, in bytes.

### HttpResponse.ContentLength64

`Chilkat 11.7.0 · pascal · HttpResponse · ContentLength64 · property · read-only`

```pascal
property ContentLength64: Int64 read GetContentLength64;
```

The content length of the response, in number of bytes, returned as a 64-bit integer.

### HttpResponse.DateStr

`Chilkat 11.7.0 · pascal · HttpResponse · DateStr · property · read-only`

```pascal
property DateStr: string read GetDateStr;
```

Returns the content of the Date response header field in RFC822 date/time string format.

### HttpResponse.Domain

`Chilkat 11.7.0 · pascal · HttpResponse · Domain · property · read-only`

```pascal
property Domain: string read GetDomain;
```

The domain of the HTTP server that created this response.

### HttpResponse.FinalRedirectUrl

`Chilkat 11.7.0 · pascal · HttpResponse · FinalRedirectUrl · property · read-only · since 9.5.0.49`

```pascal
property FinalRedirectUrl: string read GetFinalRedirectUrl;
```

Returns the redirect URL for 301/302 responses.

### HttpResponse.FullMime

`Chilkat 11.7.0 · pascal · HttpResponse · FullMime · property · read-only`

```pascal
property FullMime: string read GetFullMime;
```

Returns the full MIME (header + body) of the HTTP response.

### HttpResponse.Header

`Chilkat 11.7.0 · pascal · HttpResponse · Header · property · read-only`

```pascal
property Header: string read GetHeader;
```

The full text of the response header.

### HttpResponse.NumCookies

`Chilkat 11.7.0 · pascal · HttpResponse · NumCookies · property · read-only`

```pascal
property NumCookies: Integer read GetNumCookies;
```

The number of cookies included in the response.

### HttpResponse.NumHeaderFields

`Chilkat 11.7.0 · pascal · HttpResponse · NumHeaderFields · property · read-only`

```pascal
property NumHeaderFields: Integer read GetNumHeaderFields;
```

The number of response header fields.

### HttpResponse.StatusCode

`Chilkat 11.7.0 · pascal · HttpResponse · StatusCode · property · read-only`

```pascal
property StatusCode: Integer read GetStatusCode;
```

The status code (as an integer) from the first line of an HTTP response. If the StatusLine = `HTTP/1.0 200 OK`, the response status code returned is 200.

### HttpResponse.StatusLine

`Chilkat 11.7.0 · pascal · HttpResponse · StatusLine · property · read-only`

```pascal
property StatusLine: string read GetStatusLine;
```

The first line of an HTTP response, such as `HTTP/1.0 200 OK`.

### HttpResponse.StatusText

`Chilkat 11.7.0 · pascal · HttpResponse · StatusText · property · read-only · since 9.5.0.49`

```pascal
property StatusText: string read GetStatusText;
```

The text that follows the status code in the 1st line of the HTTP response. For example, i the first line of an HTTP response is `HTTP/1.0 200 OK`, then this property contains `OK`.

### HttpResponse.UncommonOptions

`Chilkat 11.7.0 · pascal · HttpResponse · UncommonOptions · property · read/write · since 9.5.0.89`

```pascal
property UncommonOptions: string read GetUncommonOptions write SetUncommonOptions;
```

This is a catch-all property to be used for uncommon needs. Can be set to a list of the following comma separated keywords:

- `TakeResponseBody` - Introduced in v9.5.0.89. The GetBody\* methods will transfer the body to the target object instead of copying the contents. This can be useful if the response body is extremely large because it will reduce the overall memory requirement.

## Methods

### HttpResponse.GetBodyBd

`Chilkat 11.7.0 · pascal · HttpResponse · GetBodyBd · method · since 9.5.0.64`

```pascal
// binData is a TBinData object.

function  GetBodyBd(binData: TChilkatBase): Boolean;
```

Copies the response body to a BinData object.

Returns True for success, False for failure.

### HttpResponse.GetBodyJarr

`Chilkat 11.7.0 · pascal · HttpResponse · GetBodyJarr · method · since 9.5.0.89`

```pascal
// jarr is a TJsonArray object.

function  GetBodyJarr(jarr: TChilkatBase): Boolean;
```

Loads the JSON array response body into a JsonArray This method should only be called when it is known that the response body contains a JSON array (beginning with a square bracket '\[' and ending with a square bracket '\]')

Returns True for success, False for failure.

### HttpResponse.GetBodyJson

`Chilkat 11.7.0 · pascal · HttpResponse · GetBodyJson · method · since 9.5.0.89`

```pascal
// json is a TJsonObject object.

function  GetBodyJson(json: TChilkatBase): Boolean;
```

Loads the JSON response body into a JsonObject. This method should only be called when it is known that the response body contains JSON (beginning with a curly brace '{' and ending with a curly brace '}')

Returns True for success, False for failure.

### HttpResponse.GetBodySb

`Chilkat 11.7.0 · pascal · HttpResponse · GetBodySb · method · since 9.5.0.64`

```pascal
// sb is a TStringBuilder object.

function  GetBodySb(sb: TChilkatBase): Boolean;
```

Copies the response body to a Chilkat StringBuilder object.

Returns True for success, False for failure.

### HttpResponse.GetBodyXml

`Chilkat 11.7.0 · pascal · HttpResponse · GetBodyXml · method · since 9.5.0.89`

```pascal
// xml is a TXml object.

function  GetBodyXml(xml: TChilkatBase): Boolean;
```

Loads the XML response body into an XML object. This method should only be called when it is known that the response body contains XML.

Returns True for success, False for failure.

### HttpResponse.GetCookieDomain

`Chilkat 11.7.0 · pascal · HttpResponse · GetCookieDomain · method`

```pascal
function  GetCookieDomain(index: Integer): string;
```

Returns the domain of the Nth cookie in the response. Indexing begins at 0. The number of response cookies is specified in the NumCookies property.

Returns True for success, False for failure.

### HttpResponse.GetCookieExpiresStr

`Chilkat 11.7.0 · pascal · HttpResponse · GetCookieExpiresStr · method`

```pascal
function  GetCookieExpiresStr(index: Integer): string;
```

Returns the expiration date/time of the Nth cookie in the response. Indexing begins at 0. The number of response cookies is specified in the NumCookies property.

Returns True for success, False for failure.

### HttpResponse.GetCookieName

`Chilkat 11.7.0 · pascal · HttpResponse · GetCookieName · method`

```pascal
function  GetCookieName(index: Integer): string;
```

Returns the name of the Nth cookie returned in the response. Indexing begins at 0. The number of response cookies is specified in the NumCookies property.

Returns True for success, False for failure.

### HttpResponse.GetCookiePath

`Chilkat 11.7.0 · pascal · HttpResponse · GetCookiePath · method`

```pascal
function  GetCookiePath(index: Integer): string;
```

Returns the path of the Nth cookie returned in the response. Indexing begins at 0. The number of response cookies is specified in the NumCookies property.

Returns True for success, False for failure.

### HttpResponse.GetCookieValue

`Chilkat 11.7.0 · pascal · HttpResponse · GetCookieValue · method`

```pascal
function  GetCookieValue(index: Integer): string;
```

Returns the value of the Nth cookie returned in the response. Indexing begins at 0. The number of response cookies is specified in the NumCookies property.

Returns True for success, False for failure.

### HttpResponse.GetHeaderField

`Chilkat 11.7.0 · pascal · HttpResponse · GetHeaderField · method`

```pascal
function  GetHeaderField(const fieldName: string): string;
```

Returns the value of a response header field accessed by field name.

Returns True for success, False for failure.

### HttpResponse.GetHeaderFieldAttr

`Chilkat 11.7.0 · pascal · HttpResponse · GetHeaderFieldAttr · method`

```pascal
function  GetHeaderFieldAttr(const fieldName: string;
    const attrName: string): string;
```

Returns a response header field attribute. As an example, the response charset is simply the GetHeaderFieldAttr(`content-type`,`charset`)

Returns True for success, False for failure.

### HttpResponse.GetHeaderName

`Chilkat 11.7.0 · pascal · HttpResponse · GetHeaderName · method`

```pascal
function  GetHeaderName(index: Integer): string;
```

Gets the name of the Nth response header field. Indexing begins at 0. The number of response headers is specified by the NumHeaderFields property.

Returns True for success, False for failure.

### HttpResponse.GetHeaderValue

`Chilkat 11.7.0 · pascal · HttpResponse · GetHeaderValue · method`

```pascal
function  GetHeaderValue(index: Integer): string;
```

Gets the value of the Nth response header field. Indexing begins at 0. The number of response headers is specified by the NumHeaderFields property.

Returns True for success, False for failure.

### HttpResponse.LoadTaskResult

`Chilkat 11.7.0 · pascal · HttpResponse · LoadTaskResult · method · since 9.5.0.52`

```pascal
// task is a TTask object.

function  LoadTaskResult(task: TChilkatBase): Boolean;
```

Loads the HTTP response from a completed asynchronous task. A failed return value indicates that no HTTP response was received in the HTTP asynchronous method call (i.e. the asynchronous HTTP request failed in such a way that no response was received).

Returns True for success, False for failure.

### HttpResponse.SaveBodyBinary

`Chilkat 11.7.0 · pascal · HttpResponse · SaveBodyBinary · method`

```pascal
function  SaveBodyBinary(const path: string): Boolean;
```

Saves the body of the HTTP response to a file.

Returns True for success, False for failure.

### HttpResponse.SaveBodyText

`Chilkat 11.7.0 · pascal · HttpResponse · SaveBodyText · method`

```pascal
function  SaveBodyText(bCrlf: Boolean;
    const path: string): Boolean;
```

Saves the HTTP response body to a file. This method provides control over CRLF vs bare-LF line-endings. If `bCrlf` is `True`, then line endings are automatically converted to CRLF if necessary. If `bCrlf` is `False`, then line-endings are automatically converted to bare-LF's (Unix style) if necessary.

To save the HTTP response body exactly as-is (with no line-ending manipulation), then call SaveBodyBinary.

Returns True for success, False for failure.

### HttpResponse.UrlEncParamValue

`Chilkat 11.7.0 · pascal · HttpResponse · UrlEncParamValue · method`

```pascal
function  UrlEncParamValue(const encodedParamString: string;
    const paramName: string): string;
```

Convenience method for parsing a param's value out of a URL-encoded param string. For example, if a caller passes the following string in `encodedParamString`:

```
oauth_token=ABC&oauth_token_secret=123&oauth_callback_confirmed=true
```

and `oauth_token_secret` in `paramName`, then the return value would be `123`.

Returns True for success, False for failure.

## Related classes

[`BinData`](https://www.chilkatsoft.com/ai-docs/v/11.7.0/pascal/classes/BinData.md), [`JsonArray`](https://www.chilkatsoft.com/ai-docs/v/11.7.0/pascal/classes/JsonArray.md), [`JsonObject`](https://www.chilkatsoft.com/ai-docs/v/11.7.0/pascal/classes/JsonObject.md), [`StringBuilder`](https://www.chilkatsoft.com/ai-docs/v/11.7.0/pascal/classes/StringBuilder.md), [`Xml`](https://www.chilkatsoft.com/ai-docs/v/11.7.0/pascal/classes/Xml.md)

