Class wwHTTP

The wwHTTP class provides HTTP access via WinInet to Visual FoxPro application. This class provides tight control over most aspects of the HTTP protocol including HTTP headers (client and server side), timeouts, proxy support, authentication as well as providing support for asynchronous HTTP operation.

This class does not require wwIPStuff.dll with the following exceptions:

Based on: Relation
Stored in: wwHTTP.prg

Relation
  wwHttp

Class Members

MemberDescription
OnHttpBufferUpdate This method can be used to display progress information on downloads. It gets called whenever the receive buffer is updated on an HTTPGetEx update.
OnHttpPostConnect This event fires after the Http connection has been established and can be useful to set specific WinInet options on the HTTP connection.
wwHTTP Utility methods wwHTTP also includes a couple of extra utility methods that are not directly related to HTTP operation. These methods are also found and documented in wwIPStuff:
AddHeader Allows you to add HTTP headers to the HTTP request sent to the server. Headers can be of the standard HTTP header kind like Content-encoding or Cache, or custom headers specific to your application.
o.AddHeader(lcHeader,lcValue)
AddPostKey Adds a POST key and value pair to be used in a POST operation with HTTPGet and HTTPGetEx().
o.AddPostKey(tcKey, tcValue, tlIsFile)
GetSystemErrorMsg Returns a WinInet or Win32 API error message.
o.getsystemerrormsg(lnErrorNo, llAPI)
HttpCancelDownload Cancels a download if OnHttpBufferUpdate are hooked up to do incremental URL downloads. When called cancels the current download.
o.httpcanceldownload()
HttpClose Closes an HTTP Session opened with HTTPConnect(). This method is automatically called during DESTROY.
o.httpclose()
HttpConnect This HTTP method initiates a low level HTTP request for use with HTTPGetEx by establishing an IP Session and connecting to a target server. The main purpose of this method is to specify the server name and the security options when connecting.
o.httpconnect(lcServer, lcUsername, lcPassword, llHTTPS)
HttpGet Retrieves an HTTP request such as an HTML document or XML data from a Web server using standard URL syntax. Despite its name this method can also POST data to the server.
o.HttpGet(lcUrl, lcUsername, lcPassword, lcOutputFile)
HttpGetEx This method is the full featured HTTP access method that provides full support for the HTTP protocol including POST data, Basic Authentication and HTTPS protocol support. Requires HTTPConnect() to open a connection first and HTTPClose() to shut down.
o.HTTPGetEx(tcPage, @tcBuffer, @tnBufferSize, tcHeaders, tcFileName)
HttpGetExAsync Allows you to retrieve HTTP content asynchronously and store the result value into a file. Client code can poll for the result file to retrieve the Async content.
o.HTTPGetExAsync(tcPage,tcResultFile,tnResultSize,tcHeaders)
HttpGetHeader Retrieves just the HTTP header from a URL. Useful for retrieving information about a request prior to actually downloading the full URL. You can spy the content length from the header for example.
o.httpgetheader(tcPage, tcHeaders, tnHeaderSize)
HttpPing Use this method to 'ping' a Web site that is known to be up to check whether a valid Internet Connection can be made. You can specify a timeout value that determines how long this request runs and waits for finding the site in question.
o.HTTPPing(lnTimeout,lcUrl)
InternetCrackUrl This method breaks down an incoming URL into its component pieces.
loUrl = o.InternetCrackUrl(lcUrl)
SetOption Sets an Internet option on a given connection handle. The handle can be either an Internet handle or the Http handle so this method has to be called after the connection has been opened. It is meant primarily for internal purposes.
o.SetOption(lnHandle,lnOptionId,lnOptionValue)
WinInetSetTimeout Allows setting the timeout period for an HTTP request. The timeout is specified in seconds and controls how long a Connect, Read or Send operation waits before being considered timed out.
o.wininetsettimeout(dwTimeoutSecs)
cContentType Optional content type for POST data that is sent to the server.
cErrorMsg Last Error Message Text for the last operation. Implemented only for SMTP and HTTP operations.
cExtraHeaders Allows you to specify extra HTTP or SMTP headers when sending requests to Web Servers or SMTP serveres.
chttpheaders This property is set when calling HTTPGetEx and contains the entire HTTP header of a request. This property is a result property only after an HTTP request completes. Use cExtraHeaders to specify custom headers when sending requests to the Web server (or the parameter in HTTPGetEx).
cHTTPProxyByPass This property allows you to specify a list of host names or IP Addresses that should not be routed through the proxy server. IOW, this list allows you to directly access the requested domains/IPs bypassing the proxy.
cHTTPProxyName Use this method to override proxy information if the default Proxy connection types via nHTTPConnectType don't work for you.
cHttpProxyUserName Proxy server user name if the proxy requires a login.
cLink HTTP Link to visit on a site. Site relative URL. Example: /default.asp, /, /wconnect.dll?wwDemo~TestPage
cpassword Password to log on to server (applies to FTP and HTTP)
cResultCode Returns the HTTP result code from a request. These are HTTP spec result codes that are typically returned in the HTTP response header from the Web Server.
cserver HTTP Server Address. Format: www.west-wind.com, or 111.111.111.111
cUserAgent The name of the user agent that the wwIPStuff client sends to the Web server. Change this property if you need to emulate a specific browser like Internet Explorer or Netscape.
cusername Username for log in operations (FTP and HTTP).
lAllowGZip Determines whether wwHTTP requests and decodes GZip content.
lCacheRequest If set causes the current request to be cached if possible so that subsequent requests do not go back to the server to retrieve the data.
lHttpCancelDownload Property that can be read to see whether the current request was cancelled with HTTPCancelDownload.
lIgnoreCertificateWarnings When .T. ignores warnings about invalid certificates. If the server responds with warnings rather than a complete revoked and out of date certificate, these warnings are ignored and the request continues as normal. The default behavior is that any warning causes an error.
nClientCertificateIndex If a client certificate is requested this flag determines which certificate is used by a zero based numeric index. By default the first is used (0).
nconnecttimeout Allows setting the timeout period for an HTTP request. The timeout is specified in seconds and controls how long a Connect, Read or Send operation waits before being considered timed out.
nerror The last error code from an HTTP operation. Same as the value return by HttpGetEx typically.
nHttpConnectType Allows to specify how the connection is opened.
nHttpPostMode HTTP Post mode determines how requests are posted to the server. 1 - Form URLEncoded (default) 2 - Multipart forms. This property must be set prior to calling AddPostKey and HTTPGetEx
nHttpServiceFlags Flags that are used on the HTTP connection in WinInet. These are passed to WinInet call of HttpOpenRequest(). For Internet Connection Handle options use nServiceFlags instead.
nhttpworkbuffersize Size of the download HTTP buffer used while downloading dynamically sized requests with HTTPGetEx. This is the size of chunks that will be pulled at a time and also determines how often OnHTTPBufferUpdate is called.
nServiceFlags Use this property to override internet service connection flags used by WinINet. Used in the call to InternetConnect().

Requirements

See also:

Class wwHTTP

  Last Updated: 1/24/2008 | © West Wind Technologies, 2008