Skip to main content

SalHttpClient

Namespace: PPJ.Runtime.Internet

Assembly: PPJ.Runtime.50 (5.0.0.0)

Provides synchronous HTTP text retrieval with cancellable status notifications.

public class SalHttpClient : IDisposable

Example:

using PPJ.Runtime.Internet;

using (var client = new SalHttpClient())
{
client.Agent = "MyApplication/1.0";
}

Constructors

Instance member SalHttpClient()

Initializes the HTTP client with the supplied user-agent setting, if any.

Instance member SalHttpClient(agent)

Initializes the HTTP client with the supplied user-agent setting, if any.

NameTypeDescription
agentStringThe User-Agent header value.

Properties

Instance member Agent

String: Gets or sets the User-Agent header applied to HTTP requests.

Instance member Proxy

WebProxy: Gets or sets the proxy applied by GetPage.

GetPageSize does not apply this property.

Methods

Instance member Dispose()

Completes the disposable compatibility contract.

Requests close their streams and responses within each operation; this method has no additional effect.

Instance member GetPage(url)

Synchronously retrieves an HTTP response body as text.

ParameterTypeDescription
urlStringThe HTTP resource address.

Returns: String. The complete response body.

Raises status notifications and wraps WebException in HttpException. The response stream uses StreamReader's default encoding.

Instance member GetPageSize(url)

Requests a resource and reads its reported content length.

ParameterTypeDescription
urlStringThe HTTP resource address.

Returns: Int64. The Content-Length reported by the response, or -1 when unknown.

Performs a normal request rather than HEAD. This method does not apply Proxy. WebException is wrapped in HttpException.

Events

Instance member StatusUpdate

HttpEventHandler Occurs as the client advances through an operation.

Subscribers can cancel connecting, sending, receiving, and transfer-start notifications, and page loading by setting Cancel; cancellation raises HttpException with code zero.