SalHttpClient
Namespace: PPJ.Runtime.Internet
Assembly: PPJ.Runtime.50 (5.0.0.0)
Provides synchronous HTTP text retrieval with cancellable status notifications.
- C#
- VB.NET
public class SalHttpClient : IDisposable
Public Class SalHttpClient
Inherits IDisposable
Example:
using PPJ.Runtime.Internet;
using (var client = new SalHttpClient())
{
client.Agent = "MyApplication/1.0";
}
Constructors
SalHttpClient()
Initializes the HTTP client with the supplied user-agent setting, if any.
SalHttpClient(agent)
Initializes the HTTP client with the supplied user-agent setting, if any.
| Name | Type | Description |
|---|---|---|
| agent | String | The User-Agent header value. |
Properties
Agent
String: Gets or sets the User-Agent header applied to HTTP requests.
Proxy
WebProxy: Gets or sets the proxy applied by GetPage.
GetPageSize does not apply this property.
Methods
Dispose()
Completes the disposable compatibility contract.
Requests close their streams and responses within each operation; this method has no additional effect.
GetPage(url)
Synchronously retrieves an HTTP response body as text.
| Parameter | Type | Description |
|---|---|---|
| url | String | The 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.
GetPageSize(url)
Requests a resource and reads its reported content length.
| Parameter | Type | Description |
|---|---|---|
| url | String | The 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
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.