Class: cHttpTransfer

Properties  Events  Methods    Index of Classes

Implements HTTP client-side operations

Hierarchy

cObject
---InetTransfer
------cBaseHTTPTransfer
---------cHttpTransfer
------------cJsonHttpTransfer
------------cXmlHttpTransfer

Library: Common (Windows and Web Application) Class Library

Package: cHttpTransfer.pkg

Description

The cHttpTransfer class implements HTTP client-side operations.

To communicate with an internet/intranet HTTP server, you must first create an object of this class, and then set the psRemoteHost property to the fully qualified domain name, or the IP address, of the HTTP server. If your network requires traffic to go through a proxy server, you should also set the psProxy property to the protocol for the proxy server, and the fully qualified domain name or IP address of that proxy server. Unless the remote HTTP server listens to port rpHttp (80 - the default), you also have to set the piRemotePort property to the specified port number.

User name and Password

If your Http site requires that you login, you may provide a username and password using the psUserName and psPassWord properties. Alternately, you can set the pbShowErrorDialog to True, which will cause a login dialog to popup when needed.

HTTPS - Secure SSL sites

This class can be used to access secure sites. A secure HTTPS site is usually accessed over a different port - rpHttpSSL (443), which you should set using piRemotePort. In addition, a secure site will require that you add the ifSecure to your transfer flags, which you set using peTransferFlags.

// properties to set to access an HTTPS site
Set piRemotePort to rpHttpSSL
Set peTransferFlags to ifSecure

In some cases, your secure site may require that you proivde a client certificate. The certificate may be selected using the SelectClientCertificate message. It may also be selected by the user by setting pbShowErrorDialog property to true. In both, cases a client certificate must be installed on your client computer.


Sample

This sample shows the equivalent to entering "http://www.dataaccess.eu/Normal.asp?pageid=1401" in the URL address line of a browser, with the exception that the URL will show its contents in a browser interpreted as HTML; instead the example saves the information to the MyOutPut.txt file.

Use Windows.pkg
Use cHtmlHelp.pkg
Use cApplication.pkg

Object oHtmlHelp is a cHtmlHelp
End_Object

Object oApplication is a cApplication
    Set pbPreserveEnvironment to False
    Set peHelpType to htHtmlHelp
End_Object

Use cHttpTransfer.pkg

Object oHttpTransfer is a cHttpTransfer
    Set psRemoteHost to "www.dataaccess.eu"
    Set pbShowErrorDialog to True

    Function DoDownloadFile String sFile Returns Integer
        Integer iRetVal

        Set psSaveAsFile to sFile
        Send ClearHeaders
        Get HttpGetRequest "Normal.asp?pageid=1403" to iRetVal

        Function_Return iRetVal
    End_Function
End_Object

Procedure Test Global
    String sFile
    Integer iVal

    Move "c:\tmp\MyOutPut.txt" to sFile
    Get DoDownloadFile of oHttpTransfer sFile to ival
End_Procedure

Send Test