Class
HttpResponse

Class wrapper of an HTTP response.

Definition

Namespace:ArtOfTest.WebAii.Messaging.Http

Assembly:ArtOfTest.WebAii.dll

Syntax:

cs-api-definition
public class HttpResponse

Inheritance: objectHttpResponse

Constructors

HttpResponse()

Internal use only. Required for serialization.

Declaration

cs-api-definition
public HttpResponse()

HttpResponse(HttpResponse)

Copy constructor

Declaration

cs-api-definition
public HttpResponse(HttpResponse toCopy)

Parameters

toCopy

HttpResponse

The HttpResponse object to create a new copy of

HttpResponse(int, HttpRequest)

Create a response object containing an error message

Declaration

cs-api-definition
public HttpResponse(int errorCode, HttpRequest request)

Parameters

errorCode

int

The HTTP status code of the error

request

HttpRequest

The request that caused the error

Properties

Content

Gets or sets the message body. To remove the body from a message, set Content to null.

Declaration

cs-api-definition
public byte[] Content { get; set; }

Property Value

byte[]

Remarks

Sets the Content-Length header field to the length of the new message body.

Removes any existing Transfer-Encoding header. If you want to add a message body that is transfer-encoded, you must set the transfer coding for the body after assigning to the message's Content property.

Guid

Gets the unique identifier for this request object

Declaration

cs-api-definition
public Guid Guid { get; }

Property Value

Guid

Headers

Gets / Sets the response headers

Declaration

cs-api-definition
public NameValueCollection Headers { get; set; }

Property Value

NameValueCollection

HttpVersion

Gets the HTTP version string the server used for this response

Declaration

cs-api-definition
public string HttpVersion { get; set; }

Property Value

string

IsImage

Gets whether this response contains an image (according to its content-type header)

Declaration

cs-api-definition
public bool IsImage { get; }

Property Value

bool

IsXml

Gets whether this response contains an XML document (according to its content-type header)

Declaration

cs-api-definition
public bool IsXml { get; }

Property Value

bool

MimeType

Gets an array containing all the values specified as MIME types for the content of this response

Declaration

cs-api-definition
public string[] MimeType { get; }

Property Value

string[]

Request

Gets the request object that caused this response

Declaration

cs-api-definition
public HttpRequest Request { get; }

Property Value

HttpRequest

StatusCode

Gets / Sets the HTTP status code for this response

Declaration

cs-api-definition
public int StatusCode { get; set; }

Property Value

int

StatusDescription

Gets / Sets the status description string (e.g. "OK", "Not Found") for this response. Note: Legacy content could include the preceding status code (e.g. "200 OK", "404 Not Found").

Declaration

cs-api-definition
public string StatusDescription { get; set; }

Property Value

string

Timestamp

The time at which this response was received from the server

Declaration

cs-api-definition
public DateTime Timestamp { get; set; }

Property Value

DateTime

Methods

AddHeader(string, string)

Adds a new header to this response's headers. If there is already a header by the same name, the value specified in thie call is added to the list of values for the header.

Declaration

cs-api-definition
public void AddHeader(string name, string value)

Parameters

name

string

The header's name

value

string

The value for the header

AppendHeader(string, string)

Adds a new header to this response's headers. If there is already a header by the same name, the value specified in thie call is added to the list of values for the header.

Declaration

cs-api-definition
public void AppendHeader(string name, string value)

Parameters

name

string

The header's name

value

string

The value for the header

CleanUpConnectionOptions()

Strips out any headers matching the tokens listed in the Connection header, and removes all tokens from the Connection header.

Declaration

cs-api-definition
public void CleanUpConnectionOptions()

Clear()

Clears all headers and content output from the current response

Declaration

cs-api-definition
public void Clear()

ClearContent()

Clears the content buffer for the current response

Declaration

cs-api-definition
public void ClearContent()

ClearHeaders()

Clears all headers from the current response

Declaration

cs-api-definition
public void ClearHeaders()

GetUnchunkedContent()

Declaration

cs-api-definition
public byte[] GetUnchunkedContent()

Returns

byte[]

ToString()

Gets the string representation of this object.

Declaration

cs-api-definition
public override string ToString()

Returns

string

String representation of this object.

Overrides object.ToString()

ToString(bool)

Converts this HttpResponse to a string representation.

Declaration

cs-api-definition
public string ToString(bool printHeaders)

Parameters

printHeaders

bool

Whether or not to include the HTTP headers in the converted string.

Returns

string

A string representation of this object.