SafeHttpWebResponse

SafeHttpWebResponse is a more secure replacement of System.Net.HttpWebResponse to get HTTP responses.

Usage

Namespace

VisionCritical.PanelPlus.Responding

Properties:

Name Type Description
CharacterSet string Gets the character set of the response.
ContentEncoding string Gets the method that is used to encode the body of the response.
ContentLength string Gets the length of the content returned by the request.
ContentType string Gets the content type of the response.
Cookies CookieCollection Gets or sets the cookies that are associated with this response.
Headers WebHeaderCollection Gets the headers that are associated with this response from the server.
IsFromCache boolean Gets a boolean value that indicates whether this response was obtained from the cache.
IsMutuallyAuthenticated boolean Gets a boolean value that indicates whether both client and server were authenticated.
LastModified DateTime Gets the last date and time that the contents of the response were modified.
Method string Gets the method that is used to return the response.
ProtocolVersion Version Gets the version of the HTTP protocol that is used in the response.
ResponseUri Uri Gets the URI of the Internet resource that responded to the request.
Server string Gets the name of the server that sent the response.
StatusCode HttpStatusCode Gets the status of the response.
StatusDescription string Gets the status description returned with the response.
SupportsHeaders bool Gets a value that indicates if headers are supported.

Methods

Close()

Closes the response stream.

ReturnType void

GetResponseHeader(headerName)

Gets the contents of a header that was returned with the response.

Name Type Description
headerName string The header value to return.

ReturnType Stream

Example

var request = new VisionCritical.PanelPlus.Responding.SafeHttpWebRequest("http://www.visioncritical.com", "POST");
request.Body = System.Text.Encoding.UTF8.GetBytes("Body text");
var response = request.GetSafeResponse();
var header= response.GetResponseHeader("ContentType");

GetResponseStream()

Gets the stream that is used to read the body of the response from the server.

ReturnType Stream

Example

var request = new VisionCritical.PanelPlus.Responding.SafeHttpWebRequest("http://www.visioncritical.com", "POST");
request.Body = System.Text.Encoding.UTF8.GetBytes("Body text");
var response = request.GetSafeResponse();
var stream= response.GetResponseStream();

GetResponseString(encoding {optional})

Gets the body of the response and returns it as a string.

Parameters:
Name Type Description
encoding Encoding The encoding to be used for the string (optional will default to UTF8).

ReturnType string

Example

var request = new VisionCritical.PanelPlus.Responding.SafeHttpWebRequest("http://www.visioncritical.com", "POST");
request.Body = System.Text.Encoding.UTF8.GetBytes("Body text");
var response = request.GetSafeResponse();
var responseString = response.GetResponseString();

GetResponseList()

Gets the body of the response and returns it as a list of strings.

ReturnType List<string>

Example

var request = new VisionCritical.PanelPlus.Responding.SafeHttpWebRequest("http://www.visioncritical.com", "POST");
request.Body = System.Text.Encoding.UTF8.GetBytes("Body text");
var response = request.GetSafeResponse();
for each (string line in response.GetResponseList())
{
   string lineText = line;
}

GetResponseBytes()

Gets the body of the response and returns it as a byte array.

ReturnType byte[]

Example

var request = new VisionCritical.PanelPlus.Responding.SafeHttpWebRequest("http://www.visioncritical.com", "POST");
request.Body = System.Text.Encoding.UTF8.GetBytes("Body text");
var response = request.GetSafeResponse();
var responseBytes = response.GetResponseBytes();