SafeHttpWebRequest

SafeHttpWebRequest is a more secure replacement of System.Net.WebRequest and System.Net.HttpWebRequest to make HTTP web requests.

Usage

Namespace

VisionCritical.PanelPlus.Responding

Constructor

SafeHttpWebRequest(URL, Method)

Parameters:

Name Type Description
URL string The URI that identifies the Internet resource.
Method string The request method to use to contact the Internet resource. The default value is GET.
Example GET request
SafeHttpWebRequest request = new VisionCritical.PanelPlus.Responding.SafeHttpWebRequest("http://www.visioncritical.com", "GET");
Example POST request
SafeHttpWebRequest request = new VisionCritical.PanelPlus.Responding.SafeHttpWebRequest("http://www.visioncritical.com", "POST");

SafeHttpWebRequest(RequestUri)

Parameters:

Name Type Description
RequestUri Uri A Uri containing the URI of the requested resource.
Example request
SafeHttpWebRequest request = new VisionCritical.PanelPlus.Responding.SafeHttpWebRequest(new Uri("http://www.visioncritical.com"));

SafeHttpWebRequest(RequestUri)

Properties:

Name Type Description
Body byte Gets or sets the body that you wish to post.
Accept string Gets or sets the value of the Accept HTTP header.
Address Uri Gets the Uniform Resource Identifier (URI)_ of the Internet resource that actually response to the request.
AllowReadStreamBuffering boolean Gets or sets a value that indicates whether the request should follow redirection responses.
AllowReadStreamBuffering boolean Gets or sets a value that indicates whether to buffer the data received from the Internet resource.
AllowWriteStreamBuffering boolean Gets or sets a value that indicates whether to buffer the data received from the Internet resource.
AuthenticationLevel AuthenticationLevel Gets or sets values indicating the level of authentication and impersonation used for this request.
AutomaticDecompression DecompressionMethods Gets or sets the type of decompression that is used.
CachePolicy RequestCachePo9licy Gets or sets the cache policy for this request
ClientCerificates X509CerticateCollection Gets or sets the collection of security certificates that are associated with this request.
Connection string Gets or sets the value of the connection HTTP header.
ConnectionGroupName string Gets or sets the name of the connection group for the request.
ContentType string Gets or sets the value of the Content-type HTTP header.
ContinueDelegate HttpContinueDelegate Gets or sets the delegate method called when an HTTP 100-continue response is received from the Internet resource.
ContinueTimeout integer Gets or sets a timeout, in milliseconds, to wait until the 100-Continue is received from the server.
CookieContainer CookieContainer Gets or sets a timeout in milliseconds, to wait until the 100-Continue is received from the server.
Credentials iCredentials Gets or sets authentication information for the request.
Date DateTime Get or set the Date HTTP header value to use in an HTTP req1uest.
Expect sting Gets or sets the value of the Expect HTTP header.
HaveResponse boolean Gets information on whether there are responses or not.
Headers WebHeaderCollection Specifies a collection of the name/value pairs that make up the HTTP headers.
Host string Get or set the Host header value to use in an HTTP request URI>
IfModifiedSince DateTime Gets or sets the value of the If-Modified_since HTTP header.
ImpersonationLevel TokenImpersonationLevel Gets or sets the impersonation level for the current request.
KeepAlive boolean Gets or sets a value that indicates whether to make a persistent connection to the Internet resource.
MaximumAutomaticRedirections integer Gets or sets the maximum allowed length.
MaximumResponseHeadersLength integer Gets or sets the maximum allowed length of the response headers.
MediaType string Gets or sets the media type of the request.
Method string Gets or sets the method for the request.
Pipelined boolean Gets or sets a value that indicates whether to pipeline the request to the Internet resource.
PreAuthenticate boolean Gets or sets a value that indicates whether to send an Authorization header with the request.
ProtocalVersion version Gets or sets the version of HTTP to use for the request.
Proxy IWebProxy Gets or sets proxy information for the request.
ReadWriteTimeout integer Gets or sets a time-out in the milliseconds when writing to or reading from a stream.
Referer string Gets or sets the value of the Referer HTTP header.
ReqestUri string Gets the original Uniform Resource Identifier (URI) of the request.
SendChunked string Gets or sets a value that indicates whether to send data in segments to the Internet resource.
ServerCertificateValidationCallback RemoteCertificateValidationCallback Gets or sets a callback function to validate the server certificate.
ServicePoint ServicePoint Gets the service point to use for the request.
SupportCookieContainer boolean Gets a value that indicates whether the request provides support of a CookieContainer.
TimeOut integer Gets or sets the time-out value in milliseconds for the GetResponse and GetRequestStream methods.
TransferEncoding string Gets or sets the value of the Transfer-encoding HTTP header.
UnsafeAuthenticatedConnectionSharing boolean Gets or sets a value that indicates whether to allow high-speed NTLM-authenticated connection sharing.
UseDefaultCredentials boolean Gets or sets a boolean value that controls whether default credentials are sent with request.
UserAgent string Gets or sets the value of the User-agent HTTP header.

Methods

Abort

Cancels a request to an Internet resource.

ReturnType void

AddRange(Int32)

Adds a byte range header to a request for a specified range from the beginning or end of the requested data.

Parameters:

Name Type Description
range integer The starting or ending point of the range.

ReturnType: void

AddRange(Int32, Int32)

Adds a byte range header to the request for a specified range.

Parmeters:

Name Type Description
from integer The position at which to start sending data.
to integer The position at which to stop sending data.

ReturnType void

AddRange(Int64)

Adds a byte range header to a request for a specific range from the beginning or end of the requested data.

Parameters:

Name Type Description
range long The starting or ending point of the range.

ReturnType void

AddRange(Int64, Int64)

Adds a byte range header to the request for a specified range.

Parameters:

Name Type Description
from long The position at which to start sending data.
to long The position at which to stop sending data.

ReturnType void

AddRange(str, Int32)

Adds a byte range header to a request for a specific range from the beginning or end of the requested data.

Parameters:

Name Type Description
rangeSpecifier string The description of the range
range integer The starting or ending point of the range.

ReturnType void

AddRange(str, Int32, Int32)

Adds a byte range header to the request for a specified range.

Parameters:

Name Type Description
rangeSpecifier string The description of the range.
from int The position at which to start sending data.
to int The position at which to stop sending data.

ReturnType void

AddRange(str, Int64)

Adds a byte range header to a request for a specific range from the beginning or end of the requested data.

Paramters:

Name Type Description
rangeSpecifier string The description of the range.
range long The starting or ending point of the range.

ReturnType void

AddRange(str, Int64, Int64)

Adds a byte range header to the request for a specified range.

Paramters:

Name Type Description
rangeSpecifier string The description of the range.
from long The position at which to start sending data.
to long The position at which to stop sending data.

ReturnType void

BeginGetRequestStream(AsyncCallback, Object)

Begins an asynchronous request for a Stream object to use to write data.

Parameters:

Name Type Description
callback AsyncCallback The AsyncCallback delegate.
state object The state object for this request.

ReturnType IAsyncResult

EndGetRequestStream(IAsyncResult)

Ends an asynchronous request for a Stream object to use to write data.

Parameters:

Name Type Description
asyncResult IAsyncResult The pending request for a stream.

ReturnType Stream

EndGetRequestStream(IAsyncResult asyncResult, out TransportContext context)

Ends an asynchronous request for a Stream object to use to write data and outputs the TransportContext associated with the stream.

Parameters:

Name Type Description
asyncResult IAsyncResult The pending request for a stream.
context TransportContext The TransportContext for the Stream.

ReturnType Stream

EndGetResponse(IAsyncResult asyncResult)

Ends an asynchronous request to an Internet resource.

Parameters:

Title Type Description
asyncResult IAsyncResult The pending request for a stream.

ReturnType SafeHttpWebResponse

GetSafeResponse()

ReturnType SafeHttpWebResponse

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();

GetRequestStream()

Gets a Stream object to use to write request data.

ReturnType Stream

GetRequestStream(TransportContext)

Gets a Stream object to use to write request data.

Parameters:

Name Type Description
context TransportContext The TransportContext for the Stream.

ReturnType Stream

GetRequestStream()

Gets a Stream object to use to write request data.

ReturnType Stream