ASP winhttp.winhttprequest.5.1 Object Use detailed information to fake HTTP headers _ Thieves/Collection

Source: Internet
Author: User
Since Microsoft blocked the XmlHttp object, it could not forge part of the HTTP header information, but winhttp.winhttprequest.5.1 object, it can successfully forge all HTTP request header information!

As you know from MSDN, winhttp.winhttprequest.5.1 is the underlying object of MSXML 4.0, which means that xmlhttp/serverxmlhttp is also encapsulated on its basis, winhttprequest usage and XmlHttp is roughly the same.

waitForResponse when sending a request asynchronously, you can use this method to control the requested process, the specified wait time, the value to be completed in seconds for an asynchronous transfer method, Settimeouts.

In a server-side script, it is not possible to use the callback function directly to control the asynchronous request as the client does, and there is no corresponding function to use the program to hibernate for a certain amount of time, so we can use this method to wait for a certain time to wait for the request to return.
Copy Code code as follows:

<%
Dim WinHttp
Set WinHttp = Server.CreateObject ("winhttp.winhttprequest.5.1")
' Set parameters
Winhttp.settimeouts 60000, 60000, 60000, 3000 ' set operation timeout
' Winhttp.settimeouts resolvetimeout, ConnectTimeout, Sendtimeout, ReceiveTimeout
' resolvetimeout = 10000 ' resolves the DNS name timeout, 10000 milliseconds.
' ConnectTimeout = 10000 ' establishes a Winsock connection timeout of 10000 milliseconds.
' Sendtimeout = 120000 timeout for sending data, 120000 milliseconds.
' ReceiveTimeout = 60000 ' receives response timeout, 60000 milliseconds.
Winhttp.option (4) = 13056 ' Ignore error flag
When winhttp.option (6) = False ' is True, automatically jumps when a page redirection jump is requested, False does not automatically jump, and intercepts the 302 states returned by the server.
Winhttp.open "Get", "http://www.baidu.com/", false ' Get or POST, URL, false sync mode; True Asynchronous method
' Compose HTTP header information
Winhttp.setrequestheader "Accept", "*/*" Accept data type
Winhttp.setrequestheader "Accept-language", "Zh-cn,zh" ' User system language
Winhttp.setrequestheader "User-agent", "mozilla/6.0" user browser information
Winhttp.setrequestheader "Content-type", "application/x-www-form-urlencoded" encoding method
Winhttp.setrequestheader "Referer", "http://www.baidu.com/" ' antecedents
Winhttp.setrequestheader "Connection", "close" ' close = does not remain connected, Keep-alive = remain connected (persistent connection)
' Winhttp.setrequestheader ' accept-encoding ', ' gzip, deflate ' ' if sent, will return gzip, deflate compressed encoded
' Winhttp.setrequestheader ' content-length ', Len (Str) ' content length, Post method.
Winhttp.setrequestheader "Cookie", "Test cookie!" ' Set cookies
' Send data
Winhttp.send ' Post method: winhttp.send (parameter)
Winhttp.waitforresponse ' waits for a return request, which can also be used in XMLHTTP
' Output results
Response.Write Winhttp.status ' Current HTTP status
' Response.Write winhttp.responsetext ' text data
Response.BinaryWrite winhttp.responsebody ' binary Data Flow data
%>

Option () Related:

winhttprequestoption_useragentstring = 0;
Winhttprequestoption_url = 1;
Winhttprequestoption_urlcodepage = 2;
Winhttprequestoption_escapepercentinurl = 3;
Winhttprequestoption_sslerrorignoreflags = 4;
Winhttprequestoption_selectcertificate = 5; ' 13056 = Ignore error flag
Winhttprequestoption_enableredirects = 6; ' True to grab jump page information when there is a jump in the requested page. False opposite does not crawl
winhttprequestoption_urlescapedisable = 7;
Winhttprequestoption_urlescapedisablequery = 8;
Winhttprequestoption_secureprotocols = 9;
winhttprequestoption_enabletracing = 10;
Winhttprequestoption_revertimpersonationoverssl = 11;
Winhttprequestoption_enablehttpstohttpredirects = 12;
Winhttprequestoption_enablepassportauthentication = 13;
Winhttprequestoption_maxautomaticredirects = 14;
Winhttprequestoption_maxresponseheadersize = 15;
Winhttprequestoption_maxresponsedrainsize = 16;
Winhttprequestoption_enablehttp1_1 = 17;
Winhttprequestoption_enablecertificaterevocationcheck = 18;

Method Description Description

Abort aborts a WinHTTP send method.
getAllResponseHeaders retrieves all HTTP response headers.
getResponseHeader retrieves the HTTP response header.
Open opens an HTTP connection to the HTTP resource.
Send sends an HTTP request to the HTTP server.
Setautologonpolicy sets the current automatic login policy.
Setclientcertificate Select a client certificate to send to a secure Hypertext Transfer Protocol (HTTPS) server.
SetCredentials set the credentials to use with the HTTP server, either the country of origin or the proxy server.
SetProxy set proxy server information.
setRequestHeader Add, change, or delete an HTTP request header.
SETTIMEOUTS specifies that the individual's time exceeds a component send/Receive operation in milliseconds.
waitForResponse The specified wait time, the value that is completed in seconds for an asynchronous transfer method, Settimeouts.

The WinHttpRequest object defines the following properties.

Attribute Access type description

Option read/write setting or retrieve an WinHTTP value.
Responsebody read-only retrieval as a response entity mechanism for unsigned byte arrays.
Responsestream read-only retrieval mechanism as the IStream of the response entity.
ResponseText is read-only as a text retrieval response entity mechanism.
Status is read-only HTTP status code from the last retrieved response.
StatusText text that gets the HTTP status read-only.

Events activities

The WinHttpRequest object defines the following events.
The following event defined by the WinHttpRequest object.

Event Events Description Description

OnError occurs when there are a run-time error in the application.
Occurs when an application Run-time error occurs.
Onresponsedataavailable occurs when the data are available from the response.
Occurs when the response data is available.
Onresponsefinished occurs the response data is complete.
Occurs when the response data is complete.
Onresponsestart occurs when the response data starts to be received.
Occurs when the response data begins to be received.

Remarks Notes

The WinHttpRequest object uses the IErrorInfo interface to provide error data.
The WinHttpRequest object uses the IErrorInfo interface to provide error data.
A description and numerical error value can is obtained with the Err object in Microsoft Visual Basic scripting Edition (V Bscript),
And the Error object in Microsoft JScript.
The lower bits of an error number correspond to the values found in error Messages.
Note For Windows XP and Windows Run-time Requirements.
Note: For Windows XP and Windows 2000, see Run time requirements.

Requirements Requirements

Minimum supported client Windows XP, Windows Professional with SP3 Windows XP
The least supported server, Windows Server 2003, Windows SQL Server with SP3

Redistributable WinHTTP 5.0 and Internet Explorer 5.01 or later on Windows XP and Windows 2000.
WinHTTP 5.0 and Internet Explorer 5.01 or later Windows XP and Windows 2000.
IDL Httprequest.idl Httprequest.idl
Library Winhttp.lib Winhttp.lib
DLL Winhttp.dll Winhttp.dll
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.