WinHttpRequest object
This topic provides information about using the WinHTTP WinHttpRequest COM object with scripting languages. For more information, including the C++ API (WinHTTP) please see About WinHTTP. See Choosing a WinHTTP Interface for a comparison of these interfaces.
Example
// Instantiate a WinHttpRequest object.
var WinHttpReq = new ActiveXObject("WinHttp.WinHttpRequest.5.1");
IWinHttpRequest * pIWinHttpRequest = NULL;
\\..
hr = CLSIDFromProgID(L"WinHttp.WinHttpRequest.5.1", &clsid);
if (SUCCEEDED(hr))
{
hr = CoCreateInstance(clsid, NULL,
CLSCTX_INPROC_SERVER,
IID_IWinHttpRequest,
(void **)&pIWinHttpRequest);
}
Code examples taken from IWinHttpRequest::Status property.
Members
The WinHttpRequest object has these types of members:
Events
The WinHttpRequest object has these events.
Event | Description |
---|---|
OnError | Occurs when there is a run-time error in the application. |
OnResponseDataAvailable | Occurs when data is available from the response. |
OnResponseFinished | Occurs when the response data is complete. |
OnResponseStart | Occurs when the response data starts to be received. |
Methods
The WinHttpRequest object has these methods.
Method | Description |
---|---|
Abort | Aborts a WinHTTP Send method. |
GetAllResponseHeaders | Retrieves all HTTP response headers. |
GetResponseHeader | Retrieves the HTTP response headers. |
Open | Opens an HTTP connection to an HTTP resource. |
Send | Sends an HTTP request to an HTTP server. |
SetAutoLogonPolicy | Sets the current Automatic Logon Policy. |
SetClientCertificate | Selects a client certificate to send to a Secure Hypertext Transfer Protocol (HTTPS) server. |
SetCredentials | Sets credentials to be used with an HTTP server either an origin or a proxy server. |
SetProxy | Sets proxy server information. |
SetRequestHeader | Adds, changes, or deletes an HTTP request header. |
SetTimeouts | Specifies, in milliseconds, the individual time-out components of a send/receive operation. |
WaitForResponse | Specifies the wait time, in seconds, for an asynchronous Send method to complete, with optional time-out value. |
Properties
The WinHttpRequest object has these properties.
Property | Access type | Description |
---|---|---|
Option |
Read/write |
Sets or retrieves a WinHTTP option value. |
ResponseBody |
Read-only |
Retrieves the response entity body as an array of unsigned bytes. |
ResponseStream |
Read-only |
Retrieves the response entity body as an IStream. |
ResponseText |
Read-only |
Retrieves the response entity body as text. |
Status |
Read-only |
Retrieves the HTTP status code from the last response. |
StatusText |
Read-only |
Retrieves HTTP status text. |
Remarks
The WinHttpRequest object uses the IErrorInfo interface to provide error data. A description and numerical error value can be obtained with the Err object in Microsoft Visual Basic Scripting Edition (VBScript), and the Error object in Microsoft JScript. The lower 16 bits of an error number correspond to the values found in Error Messages.
Note
For Windows XP and Windows 2000, see Run-Time Requirements.
Requirements
Requirement | Value |
---|---|
Minimum supported client |
Windows XP, Windows 2000 Professional with SP3 [desktop apps only] |
Minimum supported server |
Windows Server 2003, Windows 2000 Server with SP3 [desktop apps only] |
Redistributable |
WinHTTP 5.0 and Internet Explorer 5.01 or later on Windows XP and Windows 2000. |
IDL |
|
Library |
|
DLL |
|