HTTP ActiveX Control
Copyright   1996, 1997 by Distinct Corporation. All rights reserved.

Usage | Export Restrictions | Properties | Events | Methods | Header


4.1 Overview

4.1.1 Introduction

The Hypertext Transfer Protocol (HTTP) is an application-level protocol for distributed, collaborative, hypermedia information systems. This ActiveX control implements HTTP version 1.1. HTTP builds on the discipline of reference provided by the Uniform Resource Identifier (URI), as a location (URL) or name (URN), for indicating the resource to which a method is to be applied. HTTP is also used as a generic protocol for communication between user agents and proxies/gateways to other Internet systems, including those supported by the FTP, Gopher, and SOCKS protocols. In this way HTTP allows basic hypermedia access to resources available from diverse applications. The Distinct HTTP ActiveX control implements the Secure Sockets Layer (SSL 2.0) and user authentication, providing a secure way to transfer files over LANS and WANS using RSA encryption algorithms.

4.1.2 Usage

See the section entitled "Using Distinct ActiveX controls in various environments" on how to add the control to your project.

Once a HTTP ActiveX control has been placed into a form, most of the controls properties can be set at design time. However, the application may want to request information from the user at runtime before setting properties. The URL property must contain the address and path of the resource. The HTTP ActiveX control implements the GET, HEAD and POST protocol methods using the Get, Head and Post methods. The URL property must be set before calling the Get, Head or Post methods.

Before calling any other method, the Start method must be called once (generally, when the application loads) to initialize various components of the control. Similarly, before quitting the application, the Stop method must be called to cleanup the components initialized by the control. To ensure proper behavior of the control, it is important to call these methods correctly.

Some networks may have a firewall between the internal network and the outside world. In this case, the application must connect to a firewall server to access any machines outside the firewall. The HTTP ActiveX control provides built-in firewall support to achieve this. The application must set the Firewall property to FW_SOCKS to establish a connection via a SOCKS server or FW_PROXY to go through an HTTP proxy server; otherwise the Firewall property is set to FW_NONE.

If the Firewall property is set to FW_PROXY then the FirewallPort and FirewallServer properties must be set before any transaction is initiated. If the Firewall property is set to FW_SOCKS, then the FirewallServer, FirewallPort, FirewallUser and UserAgent properties must all be set before any transaction is initiated. If any of these properties are not set then the control will not go via the SOCKS server, instead the control will atttempt to connect directly to the remote host.

The application can abort the current transaction (GET, POST or HEAD) in progress using the Abort method. This will cancel the operation immediately.

The HTTP custom control has support for the HTTPS (or Secure HTTP) protocol which is a more secure form of the HTTP protocol. In this case, the data sent on the network is encrypted, and is then decrypted when received at the other end. The protocol (HTTP or HTTPS) to be used is specified in the URL property. For more information on how to specify the HTTP and HTTPS protocols, please see the documentation on the URL property.

By handling the OnReportStatus and OnReportProgress events, the application can display the status of the transfer and the number of bytes currently transferred.

Back to Top


 4.1.3 Export Restrictions

There are restrictions on the distribution of the Distinct HTTP ActiveX control. You may only export applications developed using the HTTP ActiveX control to the countries listed below.

Abu Dhabi
Argentina 
Australia 
Austria 
Belgium 
Bolivia 
Brazil 
Canada 
Chile 
Colombia 
Costa Rica 
Denmark 
Ecuador 
Finland 
France 
Germany 
Greece 
Hong Kong 
Indonesia 
Ireland 
Israel 
Italy 
Japan 
Korea (South) 
Kuwait 
Liechtenstein 
Luxembourg 
Malaysia 
Mexico 
Netherlands 
New Zealand 
Norway 
Panama 
Paraguay 
Peru 
Philippines 
Portugal 
Saudi Arabia 
Singapore 
South Africa 
Spain 
Sweden 
Switzerland 
Taiwan  
Turkey 
United Kingdom 
United States 
Uruguay 
Venezuela

Back to Top 


4.1.4 Property Summary

ContentType
Mime multipart content type

Firewall
Enable or disable firewall/proxy support

FirewallPort
Firewall server port

FirewallServer
Name or IP address of the firewall server

FirewallUser
User name for SOCKS

LastResult
Result of last command executed

URL
URL address

UserAgent
User agent

Back to Top


4.1.5 Event Summary

OnError
Local error has occurred

OnHeader
Received header information

OnReceive
Received document

OnReportProgress
Report progress of transfer

OnReportStatus
Report status of transfer

Back to Top


4.1.6 Method Summary

Abort
Abort transaction

Get
Get URL document

Head
Get header information

Post
Post document

Receive
Read data in buffer

Start
Initialize various components

Stop
Cleanup initialized components

Back to Top


4.1.7 D_HTTP.TXT

The following provides a complete listing of the D_HTTP.TXT definition file. If your application uses more than one Distinct custom control in the same form, then some definitions will conflict. For example, the FTP Client custom control includes the definition

Global Const ACTION_DISCONNECT = 3

in the D_FTP.TXT file and the Telnet custom control includes the definition

Global Const ACTION_DISCONNECT = 2

in the D_TNET.TXT file. To avoid this conflict, you must rename at least one of the constants (for example,
TP_ACTION_DISCONNECT or TNET_ACTION_DISCONNECT).

' HTTP ActiveX Control
' (C) Copyright 1996, 1997 by Distinct Corporation
' All rights reserved

' firewall constants
Global Const FW_NONE = 0
Global Const FW_SOCKS = 1
Global Const FW_PROXY = 2

' error codes
Global Const ERR_URL_NOT_DEFINED = 1
Global Const ERR_CANNOT_GET_URL = 2
Global Const ERR_IN_ACTION = 3
Global Const ERR_CANNOT_PERFORM_ACTION = 4
Global Const ERR_CANNOT_POST_URL = 5

' result
Global Const HTTP_SUCCESS = 0
Global Const HTTP_ERROR = -1
Global Const HTTP_BADARGS = -2
Global Const HTTP_LOWMEM = -3
Global Const HTTP_ABORT = -5
Global Const HTTP_BAD_HEADER = -6
Global Const HTTP_MISSING_SVC_API = -9
Global Const HTTP_MISSING_REQUEST_API = -10
Global Const HTTP_MULTIPLE_INIT = -11
Global Const HTTP_DNS_FAILED = -12
Global Const HTTP_CONNECT_FAILED = -13
Global Const HTTP_NET_FAILED = -14
Global Const HTTP_BAD_INPUTSTREAM = -15
Global Const HTTP_REQUEST_DATASINK_FAILED = -16
Global Const HTTP_NEW_DATASINK_FAILED = -17
Global Const HTTP_INVALID_REDIRECT = -18
Global Const HTTP_UNKNOWN_SERVER_ERROR = -19
Global Const HTTP_NO_UNICODE_SUPPORT = -20
Global Const HTTP_NO_UNICODE_TRANSLATION = -21
Global Const HTTP_NO_LOCALE_TRANSLATION = -22
Global Const HTTP_NO_TRANSLATION = -23
Global Const HTTP_MISSING_REQUIRED_HEADER = -24
Global Const HTTP_FILE_OPEN_ERROR = -25
Global Const HTTP_FILE_IO_ERROR = -26
Global Const HTTP_FILE_ERROR = -27

Back to Top


4.2 Properties

4.2.1 ContentType

Summary

MIME multipart content type.

Description

The ContentType property describes the MIME multipart content type of data to be posted (such as "application").

This property can be set at any time. This property has no default value.

Example

Http.ContentType = "application"

Back to Property Summary

 


4.2.2 Firewall

Summary

Enable or disable firewall/proxy support.

Description

The Firewall property enables or disables the built-in firewall support for the HTTP ActiveX control. Most corporate networks have a firewall between their internal network and the outside world. In this case, applications would have to connect to a firewall server to access the remote host.

The Firewall property can be set to one of the following values:

Value Meaning
FW_NONE Disable firewall support.
FW_SOCKS Enable SOCKS support.
FW_PROXY Enable HTTP proxy support.

The HTTP ActiveX control supports SOCKS version 4.2 as well as HTTP proxy support. If the application requires to go through a HTTP proxy server, the Firewall property must be set to FW_PROXY. If the Firewall property is set to FW_SOCKS, the HTTP ActiveX control will try to connect to a SOCKS (v4.2) server.

If the Firewall property is not set to FW_NONE, then the FirewallPort and FirewallServer properties have to be set before using the Get, Head or Post methods.

If the Firewall property is set to FW_SOCKS, then the FirewallServer, FirewallPort, FirewallUser and UserAgent properties must all be set before using the Get, Head or Post methods. If any of these properties are not set then the control will not go via the SOCKS server, instead the control will atttempt to connect directly to the remote host.

This property can be set at design time or at run time before a transaction is initiated. The default value for this property is FW_NONE.

Example

Http.Firewall = FW_SOCKS
Http.FirewallServer = "127.43.101.12"
Http.FirewallPort = "1080"
Http.FirewallUser = "john"
Http.UserAgent = "Distinct HTTP"
Http.Get ()

Back to Property Summary

 


4.2.3 FirewallPort

Summary

Firewall server port.

Description

The FirewallPort property specifies the remote port on the firewall SOCKS server (v 4.2) on which the SOCKS service resides, if the Firewall property is set to FW_SOCKS. Most SOCKS services listen for connection requests on port 1080. Sometimes, usually for security reasons, port numbers other than 1080 are used.

If the Firewall property is set to FW_PROXY, then the FirewallPort property specifies the remote port on which the HTTP proxy service resides. Most HTTP servers listen for connection requests on port 80. Sometimes, usually for security reasons, port numbers other than 80 are used.

If the application will be connecting to the SOCKS or HTTP proxy service on a different port to the default, then the FirewallPort property must be set before the connection attempt is made. An application may even want to query the user for the correct port before the transaction. The custom control does not verify the setting of the FirewallPort property and any value is therefore legal.

This property can be set at design time or at run time before a transaction is initiated. The default value for this property is port "1080" for SOCKS and "80" for HTTP proxy support.

Example

Http.FirewallPort = "1080"

Back to Property Summary

 


4.2.4 FirewallServer

Summary

Name or IP address of the firewall server.

Description

The FirewallServer property specifies the name or internet address of the remote server. If the Firewall property is set to FW_SOCKS, then the FirewallServer property specifies the SOCKS server (v4.2); otherwise for FW_PROXY the FirewallServer property specifies the HTTP proxy server. This property must be set before any transaction (Get, Head or Post), unless the Firewall property is set to FW_NONE.

There are three possible ways of specifying the remote server.

Machine Name
An application only needs to specify the name of the server if the remote server if the internet address of the server is defined in the local host table. If the server is not defined in the local host table, then the underlying protocol will contact the domain server to resolve the internet address of the server.

Machine and Domain Name
An application can specify the machine name and the domain name of the remote server. Fully domain qualified machine names are written from left to right in ascending order (eg. speedy.distinct.com). If both machine and domain names are specified, then the underlying protocol will contact the domain server to resolve the internet address of the server.

Internet Address
Sometimes the user knows only the internet address of the server that he or she wants to use. In this case, the internet address can be entered in what is known as the dotted decimal notation (eg. 127.43.101.12).

This property can be changed at design time and at run time before a connection has been established. There is no default value for this property.

Example

Http.FirewallServer = "127.43.101.12"

Back to Property Summary

 


4.2.5 FirewallUser

Summary

User name for SOCKS.

Description

The FirewallUser property specifies the user name that is to be authenticated at the SOCKS server.

If the Firewall property is set to FW_SOCKS, then the FirewallServer, FirewallPort, FirewallUser and UserAgent properties must all be set before any transaction is initiated. If any of these properties are not set then the control will not go via the SOCKS server, instead the control will atttempt to connect directly to the remote host.

This property can be changed at design time and at run time before any transaction. There is no default value for this property.

Example

Http.Firewall = FW_SOCKS
Http.FirewallServer = "127.43.101.12"
Http.FirewallPort = "1080"
Http.FirewallUser = "john"
Http.UserAgent = "Distinct HTTP"
Http.URL = "//www.distinct.com"
Http.Get ()

Back to Property Summary

 


4.2.6 LastResult

Summary

Result of last command executed.

Description

The LastResult property contains the result of the last operation. The property can have any one of the following values.

Error Value
HTTP_SUCCESS 0
HTTP_ERROR -1
HTTP_BADARGS -2
HTTP_LOWMEM -3
HTTP_ABORT -5
HTTP_BAD_HEADER -6
HTTP_MISSING_SVC_API -9
HTTP_MISSING_REQUEST_API -10
HTTP_MULTIPLE_INIT -11
HTTP_DNS_FAILED -12
HTTP_CONNECT_FAILED -13
HTTP_NET_FAILED -14
HTTP_BAD_INPUTSTREAM -15
HTTP_REQUEST_DATASINK_FAILED -16
HTTP_NEW_DATASINK_FAILED -17
HTTP_INVALID_REDIRECT -18
HTTP_UNKNOWN_SERVER_ERROR -19
HTTP_NO_UNICODE_SUPPORT -20
HTTP_NO_UNICODE_TRANSLATION -21
HTTP_NO_LOCALE_TRANSLATION -22
HTTP_NO_TRANSLATION -23
HTTP_MISSING_REQUIRED_HEADER -24
HTTP_FILE_OPEN_ERROR -25
HTTP_FILE_IO_ERROR -26
HTTP_FILE_ERROR -27

If a different value than those listed above appears, then an error occurred while the server was executing the command. The LastResult property will contain the reply code from the HTTP server.

The LastResult property reflects the result of the last operation caused by invoking the Get, Head, or Post methods.

The value of this property should be checked immediately after initiating the operation. Accessing other properties may change the value of the property.

This property can be read at any time. There is no default value for this property.

Example

Http.Get()
If Http.LastResult <> HTTP_SUCCESS Then
MsgBox "Unable to get URL", 64, "Sample Program"
End If

Back to Property Summary

 


4.2.7 URL

Summary

URL address.

Description

The URL (Universal Resource Locator) property specifies the address and path for the resource of interest. This property is used to identify the location of the resource. The URL is a formatted string that determines a network resource using a name, location, address or any other characteristic. The protocol is part of the URL string. The HTTP ActiveX control supports 2 protocols: HTTP and HTTPS.

For the HTTP protocol, the URL should have the following syntax:

"http:" "//" host [":" port] [path]

For the HTTPS protocol, the URL should have the following syntax:

"https:" "//" host [":" port] [path]

Other than these two protocols, the HTTP ActiveX control also supports the access of local files. In this case, the URL should have the following syntax:

"file:" "///" [path]

The above syntax is used to identify a resource located on the host server listening for a TCP connection on port and the location for the resource is specified by path.

The host must be a valid internet host name or dotted-decimal IP address. The port and path parameters are optional. If the port is not specified, the default port 80 is used. If the path is not present in the URL, it is given a "/" by default.

If the protocol ("http:" or "https:" or "file:") is not specified then "http:" is assumed as default. Any other protocol is invalid.

Examples of valid URL strings:

http://www.distinct.com:80/

https://www.distinct.com/

//www.distinct.com/products/

http://www.distinct.com

file:///c:\temp\index.htm

This property can be set at design time or at run time before a transaction is initiated. There is no default value for this property.

Example

Http.URL = http://www.distinct.com/

Back to Property Summary

 


4.2.8 UserAgent

Summary

User agent.

Description

The UserAgent property specifies the information for the User-Agent request-header field. This property is used to identify the user agent originating the request and can be used for statistical purposes or automated recognition of user agents.

This property should generally contain a name identifying the agent and any product information (such as version numbers) associated with the agent.

If the Firewall property is set to FW_SOCKS, then the FirewallServer, FirewallPort, FirewallUser and UserAgent properties must all be set before any transaction is initiated. If any of these properties are not set then the control will not go via the SOCKS server, instead the control will atttempt to connect directly to the remote host.

This property can be set at design time or at run time before a transaction is initiated. The default value for this property is Distinct HTTP.

Example

Http.UserAgent = "Distinct HTTP"

Back to Property Summary


4.3 Events

4.3.1 OnError

Summary

Local error has occurred.

Description

The OnError event occurs when a property is accessed in an illegal way or when a connection with the remote server cannot be established. The table below lists all possible error codes delivered by this event.

Value Meaning
ERR_URL_NOT_DEFINED URL not specified.
ERR_CANNOT_GET_URL Cannot get specifies URL.
ERR_IN_ACTION Another action is in progress.
ERR_CANNOT_PERFORM_ACTION Unable to initialize.
ERR_CANNOT_POST_URL Cannot post specified document.

The following describes each error in more detail.

ERR_URL_NOT_DEFINED
URL not specified. Make sure that the URL property is set before using the Get, Head or Post methods.

ERR_CANNOT_GET_URL
Cannot get specified URL. Make sure that the URL property contains the correct address and path. This error is returned during a Get or Head method.

ERR_IN_ACTION
Another action is already in progress.

ERR_CANNOT_PERFORM_ACTION
Unable to initialize the underlying Distinct support files. There may be a license violation or one or more of the support DLLs may be missing.

ERR_CANNOT_POST_URL
Cannot post specified document. Make sure that the URL property contains the correct address and path. This error is returned during a Post method.

Example

Sub Http_OnError (ErrorCode As Integer)
If ErrorCode = ERR_CANNOT_GET_URL Then
MsgBox "Unable to get specified URL", 64, "Sample Program"
End If
End Sub

Back to Event Summary

 


4.3.2 OnHeader

Summary

Received header information.

Description

The OnHeader event occurs in response to calling the Get or Head method. It may also occur in response to a Post method. This event delivers the MIME header information for the document. The header information will vary with the document and one or more OnHeader events will occur to deliver this information.

The OnHeader event contains two parameters: the FieldName parameter delivers the field name (such as "ContentType" or "ContentLength") and the FieldValue parameter gives the value for the field.

This MIME header information can be used by the application to decide the type of document that is being downloaded or to decide if there is enough disk space on the local machine to cache the document.

Example

Sub Http_OnHeader (FieldName As String, FieldValue As String)
' display header information
Display.Text = Display.Text + FieldName + ": " + FieldValue + vbCrLf
End Sub

Back to Event Summary

 


4.3.3 OnReceive

Summary

Received document.

Description

The OnReceive event occurs in response to calling the Get method or sometimes a Post method. this event delivers the contents of the document sent by the HTTP server.

One or more OnReceive events may occur to deliver the complete document. The Buffer parameter contains the data and Bytes indicates the length of the data.

Instead of caching the incoming data to the local disk, the application may want to display this information on screen or pass it to viewer. The Buffer could be written to a disk file, sent to another application using DDE, copied into the clipboard or scanned for the desired information and then discarded.

Normally, the Buffer property is sufficient to obtain the data in most environments. However, if you experience any problems retrieving data (eg. the environment may not support binary data within string data types), use the Receive method provided with this control. This method can be accessed inside the OnReceive event. The data in the Buffer parameter is represented in a different form by the receive method. Please check the reference page for the Receive method for more information.

Example

Sub Http_OnReceive (Buffer As String, Bytes As Long)
' display document transferred
Dim i, j As Integer
Dim Message As String
i = 1
While (i < Bytes)
j = InStr(i, Buffer, Chr(10))
If (j > 0) Then
Message = Mid(Buffer, i, j - i)
Display.Text = Display.Text + Message + Chr(13) + Chr(10)
i = j + 1
Else
Display.Text = Display.Text + Mid(Buffer, i)
i = Bytes
End If
Wend
End Sub

Back to Event Summary

 


4.3.4 OnReportProgress

Summary

Report progress of transfer.

Description

The OnReportProgress event occurs several times during an HTTP transaction to inform the application of the progress. It delivers the number of bytes transferred as and when more data is received from the other side.

The parameters Number and Total represent the number of bytes currently transferred and the total length of the document. The total length is determined by the ContentLength header information. If this information is not present in the header then Total will be -1.

As the transfer proceeds, one or more OnReportProgress events will occur to deliver the number of bytes transferred so far between the HTTP server and the client. The application can process this data and display the status of the transfer (eg. update a progress bar or status bar).

Example

Sub Http_OnReportProgress (Bytes As Long, Total As Long)
' display number of bytes transferred
NumBytes = NumBytes + Bytes
StatusBar.Panels(2).Text = "Bytes: " & NumBytes & " / " & Total
End Sub

Back to Event Summary

 


4.3.5 OnReportStatus

Summary

Report status of transfer.

Description

The OnReportStatus event occurs several times during an HTTP transaction to inform the application of the progress. It delivers the connection status of the request.

The Status parameter gives a textual information about the status of the connection. For example, the Status parameter maybe "Resolving Host Name" or "Sending Request".

As the transfer proceeds, one or more OnReportStatus events will occur to keep the application informed of the status. The application can process this data and display the status (eg. update a status bar).

Example

Sub Http_OnReportStatus (Status As String)
' display transaction status
StatusBar.Panels(1).Text = "Status: " + Status
End Sub

Back to Event Summary


4.4 Methods

4.4.1 Abort

Summary

Abort transaction.

Syntax

Boolean Abort ()

Description

To abort a transaction, call the Abort method at any time. The transaction in progress will be canceled and no further events will occur to indicate the progress or status of the transaction.

This method must be called only during a GET, HEAD or POST transaction. If this method is called at any other time, the Abort method will fail.

The Abort method returns True if successful, otherwise, it returns False.

Example

Result = Http.Abort ()
If Result = False Then
MsgBox "Unable to abort", 64, "Sample Program"
Exit Sub
End If

Back to Method Summary

 


4.4.2 Get

Summary

Get URL document.

Syntax

Boolean Get ()

Description

To retrieve a information from a Web site use the Get method. This method retrieves the resource indicated by the URL property. The OnHeader, OnReceive, OnReportProgress and OnReportStatus events will occur during this request. The URL property must be set before calling this method.

If an error occurs, then the OnError event will be fired. The application should set a flag in response to the OnError event, so that it can determine if the action was successful. In addition, the application may want to display an error message in the OnError event to inform the user of the error. Please check the reference page of the OnError event for a complete listing of error codes.

The Get method returns True if successful, otherwise, it returns False.

Example

Http.URL = "//www.distinct.com"
Result = Http.Get ()
If Result = False Then ' error
MsgBox "Unable to get specified URL", 64, "Sample Program"
Exit Sub
End If

Back to Method Summary

 


4.4.3 Head

Summary

Get header information.

Syntax

Boolean Head ()

Description

The Head method obtains the header information from the server. The body of the document is not retrieved. This header information is identical to the one received during a Get operation. This method retrieves the header of the resource indicated by the URL property. The OnHeader, OnReportProgress and OnReportStatus events will occur during this request. The URL property must be set before calling this method.

If an error occurs, then the OnError event will be fired. The application should set a flag in the OnError event, so that it can determine if the action was successful. In addition, the application may want to display an error message in the OnError event to inform the user of the error. Please check the reference page of the OnError event for a complete listing of error codes.

The Head method returns True if successful; otherwise, it returns False.

Example

Http.URL = "//www.distinct.com/"
Result = Http.Head ()

Back to Method Summary

 


4.4.4 Post

Summary

Post document.

Syntax

Boolean Post (Data, ContentType, ContentLength)
  Data Variant
  ContentType String
  ContentLength Long

Description

The Post method is used to request the server to accept the data enclosed in the request as an input for the resource indicated by the URL property. The Post method may be used to post a message to a news group or mailing list, submit a form or extend a database, etc� The actual function of the Post method is determined by the server processing the request.

The Data parameter must be set to contents to be posted. The ContentType describes the MIME multipart content type for the contents of Data (such as "application"). The ContentLength parameter is set to the length of the request contents in Data. If these parameters are not set correctly, the Post request will fail.

The server may respond to the Post operation by sending a document. In this case, the OnHeader, OnReceive, OnReportProgress and OnReportStatus events will occur.

The Post method returns True if successful, otherwise, it returns False.

Example

Dim ContentLength As Long
Dim ContentType As String
Dim PostData(32768) As Byte

Http.URL = "http://www.distinct.com/"

' filename must be defined
If Len(SFileName.Caption) = 0 Then
MsgBox "File name must be defined!", vbOKOnly + vbInformation, "HTTP Sample"
Exit Sub
End If

' set content type and content length
ContentType = "application"
ContentLength = FileLen(SFileName.Caption) ' length of file

' read entire file into buffer
Open SFileName.Caption For Binary Access Read As #1
Get #1, ContentLength, PostData
Close #1

' send document to remote host
Result = Http.Post (PostData, ContentType, ContentLength)
If Result = False Then ' error
MsgBox "Unable to POST document", vbOKOnly + vbInformation, "HTTP Sample"
End If

Back to Method Summary

 


4.4.5 Receive

Summary

Read data in buffer.

Syntax

Long Receive (RecvBuf, RecvLen)
  RecvBuf Variant
  RecvLen Long

Description

The Receive method is used to access the data received in the OnReceive event. Normally, accessing the Buffer parameter in the OnReceive event is sufficient to obtain the data that is received. However, in some environments, you may experience problems retrieving certain types of data (eg. an environment may not support binary data within string data types). In this case use the Receive method to access the data.

Whenever this method is called, as many bytes of data as possible (up to the number specified by the RecvBytes parameter of the Receive method) are copied to the RecvBuf parameter passed to the Receive method.

The Receive method takes a variant buffer (RecvBuf) and the maximum number of bytes to be copied into RecvBuf (specified by RecvLen) as its parameters, and returns a long. The Receive method copies the data received into the RecvBuf, and returns the number of bytes that was copied. In case of errors, the Receive method sets RecvBuf to NULL and returns 0. The application should ensure that the method was successfully executed by checking variant buffer or the return value.

In most cases the RecvLen will be set to the Bytes parameter of the OnReceive event. However, the application must ensure that the RecvBuf is big enough to receive RecvLen bytes of data.

Usually this method is called during an OnReceive event. This event informs the application that more data has arrived from the connected host. At this point, the application should read all the data available and process it. The Bytes parameter in the OnReceive event indicates the number of bytes received.

Example

Dim RecvBuf(1024) As Byte
Dim Len As Long

Sub Http_OnReceive (Buffer As String, Bytes As Long)
...
RecvLen = Bytes
' read data in buffer
Len = Http.Receive (RecvBuf, RecvLen)
...
End Sub

Back to Method Summary

 


4.4.6 Start

Summary

Initialize various components.

Syntax

Boolean Start ()

Description

The Start method initializes various components of the HTTP control. This method must be called once before calling any other method. The Get, Head and Post methods will fail if the control is not initialized.

Usually the Start method is called when the application is loaded. The Stop method must be called before the application quits to cleanup any initialized components.

The Start method returns True if successful, otherwise, it returns False.

Example

Result = Http.Start ()

Back to Method Summary

 


4.4.7 Stop

Summary

Cleanup initialized components.

Syntax

Boolean Stop ()

Description

The Stop method cleans up the various components initialized using the Start method. This method must be called before quitting the application. Usually the Start method is called when the application is loaded and the Stop method is called just before the application quits.

To ensure proper behavior of the HTTP control, the application must initialize and cleanup in the manner described.

The Stop method returns True if successful, otherwise, it returns False.

Example

Result = Http.Stop ()

Back to Method Summary