CSimpleHTTPClient

Implements a simple HTTP (Web) client in an COMponent.

[ SimpleWebClient | Source | Keywords | Summary | Ancestors | All Members | Descendants ]

Quick Index

DESCRIPTION
USAGE
EXAMPLE
ADMINISTRATIVE
SEE ALSO

Class Summary

class ATL_NO_VTABLE CSimpleHTTPClient :
public CComObjectRootEx<CComMultiThreadModel>,
public CComCoClass<CSimpleHTTPClient, &CLSID_SimpleHTTPClient>,
public ISupportErrorInfo,
public IDispatchImpl<ISimpleHTTPClient, &IID_ISimpleHTTPClient, &LIBID_SIMPLEWEBCLIENTLib>

{

public:
CSimpleHTTPClient() ;
STDMETHOD(DownloadPage)( BSTR BPageURL, VARIANT *pvPageContent, VARIANT *pvPageType, long lRequestedType);
STDMETHOD(get_Timeout)( long *pVal);
STDMETHOD(put_Timeout)( long newVal);
protected:
}; // CSimpleHTTPClient

Back to the top of CSimpleHTTPClient

DESCRIPTION

This component implement a very basic HTTP client:
bulletProvides one single method: Download (send an HTTP GET request and retrieve the document)
bulletProvides a timeout feature
bulletHandles WIN32 errors and provides COM error reporting (ISupportErrorInfo/IErrorInfo)
bulletSupports text data (uses BSTR) and binary data (uses SAFEARRAY of BYTEs)

This component was designed for performance; it retrieves the document in memory, it's very small (32Ko) and uses the WIN32 WinInet API (low-level API for HTTP).

Back to the top of CSimpleHTTPClient

USAGE

To use this COMponent:
bulletCreate an instance of this class
bulletOptionally, set the timeout property (in milliseconds)
bulletCall method DownloadPage
bulletDelete instance of the class

Back to the top of CSimpleHTTPClient

EXAMPLE

    <%
	    Dim oHTTP

Set oHTTP = Server.CreateObject("Emmanuel.SimpleHTTPClient.1")

Dim page_url page_url = Request.Form("PAGE_URL") Dim page_content Dim page_type

On Error Resume Next oHTTP.DownloadPage page_url, page_content, page_type

If Err <> 0 Then %> <HTML> <HEAD> <TITLE>Error When Downloading Page <%=page_url%></TITLE> </HEAD> <BODY>

<P><H2>Error When Downloading Page <%=page_url%></H2></P>

<P><B><%=Err.Description%></B></P>

</BODY> </HTML> <% Else ' No error: send back the page Response.Clear Response.ContentType = page_type Response.BinaryWrite page_content End If

%> </PRE>

Back to the top of CSimpleHTTPClient

ADMINISTRATIVE

Author Emmanuel KARTMANN - Emmanuel KARTMANN

Date Friday 2/4/00 2:48:59 PM

Back to the top of CSimpleHTTPClient

SEE ALSO

WinInet

Back to the top of CSimpleHTTPClient

CSimpleHTTPClient() ;

Purpose: create an instance of the class

Parameters: none (C++ constructor)

Return value : none (C++ constructor)

Description :

    CSimpleHTTPClient()
	                                                                                                                                             
;

Function is currently defined inline.


Back to the top of CSimpleHTTPClient

STDMETHOD(DownloadPage)( BSTR BPageURL, VARIANT *pvPageContent, VARIANT *pvPageType, long lRequestedType);

Purpose: download a document via HTTP

Parameters:

in BPageURL
Uniform Resource Locator of the document (its location)
out pvPageContent
content of the document. This variant's sub-type is the one requested (lRequestedType).
out pvPageType
type of document (the HTTP Content-Type, e.g. "text/html", "image/gif", etc...)
in lRequestedType
type of variable to create/store in pvPageContent. Can be any of the following values:
bullet0 (icString): the document is returned in a variable of type Variant/String (this is the default)
bullet1 (icVariant): the document is returned in a variable of type Variant/SafeArray of BYTEs

Return value : HRESULT = S_OK for success, otherwise an error occurred.

Description : CAUTION: if the document type is incompatible with the requested type, the page content may contain corrupted values (i.e. if you download an an image and try to store it into a string, you won't get anything useful).

	STDMETHOD(DownloadPage)(/*[in]*/ BSTR BPageURL, /*[out]*/ VARIANT *pvPageContent, /*[out]*/ VARIANT *pvPageType, /*[in, optional, default(0)]*/long lRequestedType);

Back to the top of CSimpleHTTPClient

STDMETHOD(get_Timeout)( long *pVal);

Purpose: return the timeout value (in milliseconds)

Parameters:

out pVal
current timeout value

Return value : HRESULT = S_OK for success, otherwise an error occurred.

Description : -

	STDMETHOD(get_Timeout)(/*[out, retval]*/ long *pVal);

Back to the top of CSimpleHTTPClient

STDMETHOD(put_Timeout)( long newVal);

Purpose: set the timeout value (in milliseconds)

Parameters:

in newVal
new timeout value

Return value : HRESULT = S_OK for success, otherwise an error occurred.

Description : -

	STDMETHOD(put_Timeout)(/*[in]*/ long newVal);

Back to the top of CSimpleHTTPClient

All Members

public:
STDMETHOD(DownloadPage)( BSTR BPageURL, VARIANT *pvPageContent, VARIANT *pvPageType, long lRequestedType);
STDMETHOD(get_Timeout)( long *pVal);
STDMETHOD(put_Timeout)( long newVal);
protected:

Back to the top of CSimpleHTTPClient

Ancestors

Inheritance chain for CSimpleHTTPClient:

bulletCComCoClass
bulletCComObjectRootEx
bulletIDispatchImpl
bulletISupportErrorInfo

Back to the top of CSimpleHTTPClient

Descendants

Class is not inherited by any others.

Back to the top of CSimpleHTTPClient

Generated from source by the Cocoon utilities on Mon Feb 14 10:04:23 2000 .

Report problems to jkotula@stratasys.com