You are here:

ActiveXperts.com > ActiveSocket > Objects > HTTP

ActiveSocket Toolkit Add network capabilities to any Windows or .NET application

Quicklinks


ActiveSocket - Http Object

Today, there are many software packages available to check web sites, like availability, contents, bandwidth, changes, etc.. However, most of these software tools are stand-alone packages, without scripting options. ActiveSocket is very well suited for scripting and embedding in applications.

The ActiveSocket Http object allows you to read web pages completely, so you can perform your own content checking. Use the ActiveSocket Http object to:

  • Check availability of web sites;
  • Make archives of web pages;
  • Compare web contents; for instance, read a web page every minute and notify when there's a certain change in the page;
  • Read output data of devices that provide a web interface; for instance, a Sensatronics IT Temperature device provide temperatures through a web interface (refreshed a couple of times per minute).
  • Any application that needs to read data from a web page.

The ActiveSocket Http object features the following:

  • Supports RFC 1945 and RFC 2616;
  • Support for proxy servers, including proxy authentication;
  • Support for password protected websites;
  • Support for HTTP/GET and HTTP/POST;
  • Support for SSL and HTTPs, including authentication;
  • Read data from web pages.

The Http object is part of the ActiveSocket component. Overview of all ActiveSocket objects:

Http Sample code

VBScript sample: Read a web site

   Const asERR_SUCCESS=0
   Set objHttp = CreateObject("ActiveXperts.Http")

   Do
     strUrl = inputbox( "Enter URL", "Input", "www.activexperts.com" )
   Loop until strUrl <> ""

   objHttp.Connect( strUrl )
   If( objHttp.LastError = 0 ) Then
     strData = objHttp.ReadData
     If( objHttp.LastError = 0 ) Then
       WScript.Echo strData
     End If
     objHttp.Disconnect
     WScript.Echo "Disconnect."
   End If
   WScript.Echo "Ready."

Visual C++ sample: Read a web site

   HRESULT  hr;
   IHttp    *pHttp;
   BSTR     bstrTemp

   CoInitialize( NULL );
   hr = CoCreateInstance( CLSID_Http, NULL, CLSCTX_INPROC_SERVER, 
                          IID_IHttp, (void**) &pHttp);
   pHttp->put_ProxyServer( _bstr_t( ( LPCSTR ) "proxy01" ) );
   pHttp->Connect( _bstr_t( "www.activexperts.com/about" ) );
   pHttp->get_LastError( &lLastError );
   if( lLastError != 0L )  goto _End;
   pHttp->ReadData( &bstrTemp );
   pHttp->get_LastError( &lLastError );
   if( lLastError != 0L )  goto _End;
   printf( "%ls\n", bstrTemp );
   SysFreeString( bstrTemp );
   pHttp->Disconnect();
   _End:

On ftp.activexperts-labs.com, you can find a lot of ActiveSocket samples. These samples are also part of the ActiveSocket installation.

Visit ftp.activexperts-labs.com