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

> Chilkat 11.7.0 · language=csharp · 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/csharp/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**

```csharp
Chilkat.HttpResponse obj = new Chilkat.HttpResponse();
```

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#.

Minimal complete program:

```csharp
// Required once per process. Any string unlocks a 30-day trial; use your purchased code in production.
Chilkat.Global glob = new Chilkat.Global();
if (!glob.UnlockBundle("Anything for 30-day trial"))
{
    Console.WriteLine(glob.LastErrorText);
    return;
}

Chilkat.HttpResponse httpResponse = new Chilkat.HttpResponse();

bool success = httpResponse.SaveBodyBinary("<path>");
if (!success)
{
    Console.WriteLine(httpResponse.LastErrorText);   // full diagnostic of what went wrong
    return;
}
```

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` | `public string DebugLogFilePath {get; set; }` | 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` | `public string LastErrorHtml {get; }` | read-only | Provides HTML-formatted information about the last called method or property. |
| `LastErrorText` | `public string LastErrorText {get; }` | read-only | Provides plain text information about the last called method or property. |
| `LastErrorXml` | `public string LastErrorXml {get; }` | read-only | Provides XML-formatted information about the last called method or property. |
| `LastMethodSuccess` | `public bool LastMethodSuccess {get; set; }` | read/write | Indicates the success or failure of the most recent method call: `true` means success, `false` means failure. |
| `VerboseLogging` | `public bool VerboseLogging {get; set; }` | read/write | If set to `true`, then the contents of LastErrorText (or LastErrorXml, or LastErrorHtml) may contain more verbose information. |
| `Version` | `public string Version {get; }` | read-only | Version of the component/library, such as "10.1.0" |

## Member index

| Member | Kind | Signature |
|---|---|---|
| `Body` | property, read-only | `public byte[] Body {get; }` |
| `BodyQP` | property, read-only | `public string BodyQP {get; }` |
| `BodyStr` | property, read-only | `public string BodyStr {get; }` |
| `Charset` | property, read-only | `public string Charset {get; }` |
| `ContentLength` | property, read-only | `public uint ContentLength {get; }` |
| `DateStr` | property, read-only | `public string DateStr {get; }` |
| `Domain` | property, read-only | `public string Domain {get; }` |
| `FinalRedirectUrl` | property, read-only | `public string FinalRedirectUrl {get; }` |
| `FullMime` | property, read-only | `public string FullMime {get; }` |
| `Header` | property, read-only | `public string Header {get; }` |
| `NumCookies` | property, read-only | `public int NumCookies {get; }` |
| `NumHeaderFields` | property, read-only | `public int NumHeaderFields {get; }` |
| `StatusCode` | property, read-only | `public int StatusCode {get; }` |
| `StatusLine` | property, read-only | `public string StatusLine {get; }` |
| `StatusText` | property, read-only | `public string StatusText {get; }` |
| `UncommonOptions` | property, read/write | `public string UncommonOptions {get; set; }` |
| `GetBodyBd` | method | `public bool GetBodyBd(BinData binData);` |
| `GetBodyJarr` | method | `public bool GetBodyJarr(JsonArray jarr);` |
| `GetBodyJson` | method | `public bool GetBodyJson(JsonObject json);` |
| `GetBodySb` | method | `public bool GetBodySb(StringBuilder sb);` |
| `GetBodyXml` | method | `public bool GetBodyXml(Xml xml);` |
| `GetCookieDomain` | method | `public string GetCookieDomain(int index);` |
| `GetCookieExpiresStr` | method | `public string GetCookieExpiresStr(int index);` |
| `GetCookieName` | method | `public string GetCookieName(int index);` |
| `GetCookiePath` | method | `public string GetCookiePath(int index);` |
| `GetCookieValue` | method | `public string GetCookieValue(int index);` |
| `GetHeaderField` | method | `public string GetHeaderField(string fieldName);` |
| `GetHeaderFieldAttr` | method | `public string GetHeaderFieldAttr(string fieldName, string attrName);` |
| `GetHeaderName` | method | `public string GetHeaderName(int index);` |
| `GetHeaderValue` | method | `public string GetHeaderValue(int index);` |
| `LoadTaskResult` | method | `public bool LoadTaskResult(Task task);` |
| `SaveBodyBinary` | method | `public bool SaveBodyBinary(string path);` |
| `SaveBodyText` | method | `public bool SaveBodyText(bool bCrlf, string path);` |
| `UrlEncParamValue` | method | `public string UrlEncParamValue(string encodedParamString, string paramName);` |

## Properties

### HttpResponse.Body

`Chilkat 11.7.0 · csharp · HttpResponse · Body · property · read-only`

```csharp
public byte[] Body {get; }
```

The response body returned as a byte array.

### HttpResponse.BodyQP

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

```csharp
public string BodyQP {get; }
```

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

### HttpResponse.BodyStr

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

```csharp
public string BodyStr {get; }
```

The response body returned as a string.

### HttpResponse.Charset

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

```csharp
public string Charset {get; }
```

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

```csharp
public uint ContentLength {get; }
```

The content length of the response, in bytes.

### HttpResponse.DateStr

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

```csharp
public string DateStr {get; }
```

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

### HttpResponse.Domain

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

```csharp
public string Domain {get; }
```

The domain of the HTTP server that created this response.

### HttpResponse.FinalRedirectUrl

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

```csharp
public string FinalRedirectUrl {get; }
```

Returns the redirect URL for 301/302 responses.

### HttpResponse.FullMime

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

```csharp
public string FullMime {get; }
```

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

### HttpResponse.Header

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

```csharp
public string Header {get; }
```

The full text of the response header.

### HttpResponse.NumCookies

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

```csharp
public int NumCookies {get; }
```

The number of cookies included in the response.

### HttpResponse.NumHeaderFields

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

```csharp
public int NumHeaderFields {get; }
```

The number of response header fields.

### HttpResponse.StatusCode

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

```csharp
public int StatusCode {get; }
```

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

```csharp
public string StatusLine {get; }
```

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

### HttpResponse.StatusText

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

```csharp
public string StatusText {get; }
```

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

```csharp
public string UncommonOptions {get; set; }
```

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

```csharp
public bool GetBodyBd(BinData binData);
```

Copies the response body to a BinData object.

Returns true for success, false for failure.

### HttpResponse.GetBodyJarr

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

```csharp
public bool GetBodyJarr(JsonArray 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 · csharp · HttpResponse · GetBodyJson · method · since 9.5.0.89`

```csharp
public bool GetBodyJson(JsonObject 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 · csharp · HttpResponse · GetBodySb · method · since 9.5.0.64`

```csharp
public bool GetBodySb(StringBuilder sb);
```

Copies the response body to a Chilkat StringBuilder object.

Returns true for success, false for failure.

### HttpResponse.GetBodyXml

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

```csharp
public bool GetBodyXml(Xml 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 · csharp · HttpResponse · GetCookieDomain · method`

```csharp
public string 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 `null` on failure

### HttpResponse.GetCookieExpiresStr

`Chilkat 11.7.0 · csharp · HttpResponse · GetCookieExpiresStr · method`

```csharp
public string 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 `null` on failure

### HttpResponse.GetCookieName

`Chilkat 11.7.0 · csharp · HttpResponse · GetCookieName · method`

```csharp
public string 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 `null` on failure

### HttpResponse.GetCookiePath

`Chilkat 11.7.0 · csharp · HttpResponse · GetCookiePath · method`

```csharp
public string 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 `null` on failure

### HttpResponse.GetCookieValue

`Chilkat 11.7.0 · csharp · HttpResponse · GetCookieValue · method`

```csharp
public string 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 `null` on failure

### HttpResponse.GetHeaderField

`Chilkat 11.7.0 · csharp · HttpResponse · GetHeaderField · method`

```csharp
public string GetHeaderField(string fieldName);
```

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

Returns `null` on failure

### HttpResponse.GetHeaderFieldAttr

`Chilkat 11.7.0 · csharp · HttpResponse · GetHeaderFieldAttr · method`

```csharp
public string GetHeaderFieldAttr(string fieldName, string attrName);
```

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

Returns `null` on failure

### HttpResponse.GetHeaderName

`Chilkat 11.7.0 · csharp · HttpResponse · GetHeaderName · method`

```csharp
public string 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 `null` on failure

### HttpResponse.GetHeaderValue

`Chilkat 11.7.0 · csharp · HttpResponse · GetHeaderValue · method`

```csharp
public string 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 `null` on failure

### HttpResponse.LoadTaskResult

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

```csharp
public bool LoadTaskResult(Task 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 · csharp · HttpResponse · SaveBodyBinary · method`

```csharp
public bool SaveBodyBinary(string path);
```

Saves the body of the HTTP response to a file.

Returns true for success, false for failure.

### HttpResponse.SaveBodyText

`Chilkat 11.7.0 · csharp · HttpResponse · SaveBodyText · method`

```csharp
public bool SaveBodyText(bool bCrlf, string 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 · csharp · HttpResponse · UrlEncParamValue · method`

```csharp
public string UrlEncParamValue(string encodedParamString, string 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 `null` on failure

## Related classes

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

