---
product: Chilkat
product_version: 11.7.0
language: cpp
language_label: C++
class: HttpResponse
class_name: CkHttpResponse
license: bundle
deprecated: false
reference_html: https://www.chilkatsoft.com/refdoc/vcCkHttpResponseRef.html
---
# Chilkat HttpResponse — C++ — v11.7.0

> Chilkat 11.7.0 · language=cpp · class=HttpResponse (CkHttpResponse)
> 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/cpp/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

**Object Creation**

```cpp
// Local variable on the stack
CkHttpResponse obj;

// Dynamically allocate/delete
CkHttpResponse *pObj = new CkHttpResponse();
// ...
delete pObj;
```

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 C++.

How failure is reported depends on the method's return type and is stated in the note under each method below. In every case the diagnostic text is in the `LastErrorText` property of the object whose method was called.

## 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` | `void get_DebugLogFilePath(CkString &str); const char *debugLogFilePath(void); void put_DebugLogFilePath(const char *newVal);` | 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` | `void get_LastErrorHtml(CkString &str); const char *lastErrorHtml(void);` | read-only | Provides HTML-formatted information about the last called method or property. |
| `LastErrorText` | `void get_LastErrorText(CkString &str); const char *lastErrorText(void);` | read-only | Provides plain text information about the last called method or property. |
| `LastErrorXml` | `void get_LastErrorXml(CkString &str); const char *lastErrorXml(void);` | read-only | Provides XML-formatted information about the last called method or property. |
| `LastMethodSuccess` | `bool get_LastMethodSuccess(void); void put_LastMethodSuccess(bool newVal);` | read/write | Indicates the success or failure of the most recent method call: `true` means success, `false` means failure. |
| `Utf8` | `bool get_Utf8(void); void put_Utf8(bool newVal);` | read/write | When set to `true`, all `const char *` arguments and return values are interpreted as UTF-8 strings. |
| `VerboseLogging` | `bool get_VerboseLogging(void); void put_VerboseLogging(bool newVal);` | read/write | If set to `true`, then the contents of LastErrorText (or LastErrorXml, or LastErrorHtml) may contain more verbose information. |
| `Version` | `void get_Version(CkString &str); const char *version(void);` | read-only | Version of the component/library, such as "10.1.0" |

## Member index

| Member | Kind | Signature |
|---|---|---|
| `BodyQP` | property, read-only | `void get_BodyQP(CkString &str); const char *bodyQP(void);` |
| `BodyStr` | property, read-only | `void get_BodyStr(CkString &str); const char *bodyStr(void);` |
| `Charset` | property, read-only | `void get_Charset(CkString &str); const char *charset(void);` |
| `ContentLength` | property, read-only | `unsigned long get_ContentLength(void);` |
| `ContentLength64` | property, read-only | `__int64 get_ContentLength64(void);` |
| `DateStr` | property, read-only | `void get_DateStr(CkString &str); const char *dateStr(void);` |
| `Domain` | property, read-only | `void get_Domain(CkString &str); const char *domain(void);` |
| `FinalRedirectUrl` | property, read-only | `void get_FinalRedirectUrl(CkString &str); const char *finalRedirectUrl(void);` |
| `FullMime` | property, read-only | `void get_FullMime(CkString &str); const char *fullMime(void);` |
| `Header` | property, read-only | `void get_Header(CkString &str); const char *header(void);` |
| `NumCookies` | property, read-only | `int get_NumCookies(void);` |
| `NumHeaderFields` | property, read-only | `int get_NumHeaderFields(void);` |
| `StatusCode` | property, read-only | `int get_StatusCode(void);` |
| `StatusLine` | property, read-only | `void get_StatusLine(CkString &str); const char *statusLine(void);` |
| `StatusText` | property, read-only | `void get_StatusText(CkString &str); const char *statusText(void);` |
| `UncommonOptions` | property, read/write | `void get_UncommonOptions(CkString &str); const char *uncommonOptions(void); void put_UncommonOptions(const char *newVal);` |
| `GetBodyBd` | method | `bool GetBodyBd(CkBinData &binData);` |
| `GetBodyJarr` | method | `bool GetBodyJarr(CkJsonArray &jarr);` |
| `GetBodyJson` | method | `bool GetBodyJson(CkJsonObject &json);` |
| `GetBodySb` | method | `bool GetBodySb(CkStringBuilder &sb);` |
| `GetBodyXml` | method | `bool GetBodyXml(CkXml &xml);` |
| `GetCookieDomain` | method | `bool GetCookieDomain(int index, CkString &outStr); const char *getCookieDomain(int index);` |
| `GetCookieExpiresStr` | method | `bool GetCookieExpiresStr(int index, CkString &outStr); const char *getCookieExpiresStr(int index);` |
| `GetCookieName` | method | `bool GetCookieName(int index, CkString &outStr); const char *getCookieName(int index);` |
| `GetCookiePath` | method | `bool GetCookiePath(int index, CkString &outStr); const char *getCookiePath(int index);` |
| `GetCookieValue` | method | `bool GetCookieValue(int index, CkString &outStr); const char *getCookieValue(int index);` |
| `GetHeaderField` | method | `bool GetHeaderField(const char *fieldName, CkString &outStr); const char *getHeaderField(const char *fieldName);` |
| `GetHeaderFieldAttr` | method | `bool GetHeaderFieldAttr(const char *fieldName, const char *attrName, CkString &outStr); const char *getHeaderFieldAttr(const char *fieldName, const char *attrName);` |
| `GetHeaderName` | method | `bool GetHeaderName(int index, CkString &outStr); const char *getHeaderName(int index);` |
| `GetHeaderValue` | method | `bool GetHeaderValue(int index, CkString &outStr); const char *getHeaderValue(int index);` |
| `LoadTaskResult` | method | `bool LoadTaskResult(CkTask &task);` |
| `SaveBodyBinary` | method | `bool SaveBodyBinary(const char *path);` |
| `SaveBodyText` | method | `bool SaveBodyText(bool bCrlf, const char *path);` |
| `UrlEncParamValue` | method | `bool UrlEncParamValue(const char *encodedParamString, const char *paramName, CkString &outStr); const char *urlEncParamValue(const char *encodedParamString, const char *paramName);` |

## Properties

### HttpResponse.BodyQP

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

```cpp
void get_BodyQP(CkString &str);

const char *bodyQP(void);
```

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

### HttpResponse.BodyStr

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

```cpp
void get_BodyStr(CkString &str);

const char *bodyStr(void);
```

The response body returned as a string.

### HttpResponse.Charset

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

```cpp
void get_Charset(CkString &str);

const char *charset(void);
```

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 · cpp · HttpResponse · ContentLength · property · read-only`

```cpp
unsigned long get_ContentLength(void);
```

The content length of the response, in bytes.

### HttpResponse.ContentLength64

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

```cpp
__int64 get_ContentLength64(void);
```

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

### HttpResponse.DateStr

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

```cpp
void get_DateStr(CkString &str);

const char *dateStr(void);
```

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

### HttpResponse.Domain

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

```cpp
void get_Domain(CkString &str);

const char *domain(void);
```

The domain of the HTTP server that created this response.

### HttpResponse.FinalRedirectUrl

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

```cpp
void get_FinalRedirectUrl(CkString &str);

const char *finalRedirectUrl(void);
```

Returns the redirect URL for 301/302 responses.

### HttpResponse.FullMime

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

```cpp
void get_FullMime(CkString &str);

const char *fullMime(void);
```

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

### HttpResponse.Header

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

```cpp
void get_Header(CkString &str);

const char *header(void);
```

The full text of the response header.

### HttpResponse.NumCookies

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

```cpp
int get_NumCookies(void);
```

The number of cookies included in the response.

### HttpResponse.NumHeaderFields

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

```cpp
int get_NumHeaderFields(void);
```

The number of response header fields.

### HttpResponse.StatusCode

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

```cpp
int get_StatusCode(void);
```

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 · cpp · HttpResponse · StatusLine · property · read-only`

```cpp
void get_StatusLine(CkString &str);

const char *statusLine(void);
```

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

### HttpResponse.StatusText

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

```cpp
void get_StatusText(CkString &str);

const char *statusText(void);
```

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 · cpp · HttpResponse · UncommonOptions · property · read/write · since 9.5.0.89`

```cpp
void get_UncommonOptions(CkString &str);

const char *uncommonOptions(void);

void put_UncommonOptions(const char *newVal);
```

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 · cpp · HttpResponse · GetBodyBd · method · since 9.5.0.64`

```cpp
bool GetBodyBd(CkBinData &binData);
```

Copies the response body to a BinData object.

Returns true for success, false for failure.

### HttpResponse.GetBodyJarr

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

```cpp
bool GetBodyJarr(CkJsonArray &jarr);
```

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 · cpp · HttpResponse · GetBodyJson · method · since 9.5.0.89`

```cpp
bool GetBodyJson(CkJsonObject &json);
```

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 · cpp · HttpResponse · GetBodySb · method · since 9.5.0.64`

```cpp
bool GetBodySb(CkStringBuilder &sb);
```

Copies the response body to a Chilkat StringBuilder object.

Returns true for success, false for failure.

### HttpResponse.GetBodyXml

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

```cpp
bool GetBodyXml(CkXml &xml);
```

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 · cpp · HttpResponse · GetCookieDomain · method`

```cpp
bool GetCookieDomain(int index, CkString &outStr);

const char *getCookieDomain(int index);
```

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 · cpp · HttpResponse · GetCookieExpiresStr · method`

```cpp
bool GetCookieExpiresStr(int index, CkString &outStr);

const char *getCookieExpiresStr(int index);
```

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 · cpp · HttpResponse · GetCookieName · method`

```cpp
bool GetCookieName(int index, CkString &outStr);

const char *getCookieName(int index);
```

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 · cpp · HttpResponse · GetCookiePath · method`

```cpp
bool GetCookiePath(int index, CkString &outStr);

const char *getCookiePath(int index);
```

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 · cpp · HttpResponse · GetCookieValue · method`

```cpp
bool GetCookieValue(int index, CkString &outStr);

const char *getCookieValue(int index);
```

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 · cpp · HttpResponse · GetHeaderField · method`

```cpp
bool GetHeaderField(const char *fieldName, CkString &outStr);

const char *getHeaderField(const char *fieldName);
```

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 · cpp · HttpResponse · GetHeaderFieldAttr · method`

```cpp
bool GetHeaderFieldAttr(const char *fieldName, const char *attrName, CkString &outStr);

const char *getHeaderFieldAttr(const char *fieldName, const char *attrName);
```

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 · cpp · HttpResponse · GetHeaderName · method`

```cpp
bool GetHeaderName(int index, CkString &outStr);

const char *getHeaderName(int index);
```

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 · cpp · HttpResponse · GetHeaderValue · method`

```cpp
bool GetHeaderValue(int index, CkString &outStr);

const char *getHeaderValue(int index);
```

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 · cpp · HttpResponse · LoadTaskResult · method · since 9.5.0.52`

```cpp
bool LoadTaskResult(CkTask &task);
```

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 · cpp · HttpResponse · SaveBodyBinary · method`

```cpp
bool SaveBodyBinary(const char *path);
```

Saves the body of the HTTP response to a file.

Returns true for success, false for failure.

### HttpResponse.SaveBodyText

`Chilkat 11.7.0 · cpp · HttpResponse · SaveBodyText · method`

```cpp
bool SaveBodyText(bool bCrlf, const char *path);
```

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 · cpp · HttpResponse · UrlEncParamValue · method`

```cpp
bool UrlEncParamValue(const char *encodedParamString, const char *paramName, CkString &outStr);

const char *urlEncParamValue(const char *encodedParamString, const char *paramName);
```

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/cpp/classes/BinData.md), [`JsonArray`](https://www.chilkatsoft.com/ai-docs/v/11.7.0/cpp/classes/JsonArray.md), [`JsonObject`](https://www.chilkatsoft.com/ai-docs/v/11.7.0/cpp/classes/JsonObject.md), [`StringBuilder`](https://www.chilkatsoft.com/ai-docs/v/11.7.0/cpp/classes/StringBuilder.md), [`Task`](https://www.chilkatsoft.com/ai-docs/v/11.7.0/cpp/classes/Task.md), [`Xml`](https://www.chilkatsoft.com/ai-docs/v/11.7.0/cpp/classes/Xml.md)

