HTTP Utilities Library (InetProtUtils) Example

Download

Click on the following link to download the example: ExampleInetProtUtil.zip

Click: browse to view the example code.

Description

This example code demonstrates the usage of utilities provided by the InetProtUtil API. The users should have a prior knowledge of concepts associated with it, such as URLs and URI components.

The central class is CExampleInetProtUtil , which demonstrates the following functionality:

Creating a URI

       
        
       
       void CExampleInetProtUtil::CreateUri();
      

Creates a URI with respect to the physical path of a given file.

For example, the physical path of the file:

K:/ws/direct/direct.mmp

gives the following URI file:

///k/ws/direct/direct.mmp

The screen output from this example is:

Modifying a URI

       
        
       
       void CExampleInetProtUtil::ModifyUriComponents();
      

Modifies URI components, which involves:

  1. Adding URI components, where it constructs the URI component by component. For example, you can add the following components:

    • scheme: http

    • host: waterlang.org

    • path: main_page.html

    • port: 8080

    to get the complete URI:

    http://waterlang.org:8080/main_page.html

    The screen output from this example is:

  2. Removing the specific URI component(s) from a constructed URI. For example, the above URI with the port number removed:

    http://waterlang.org/main_page.html

    The screen output from this example is:

Resolving a URI

       
        
       
       void CExampleInetProtUtil::ResolveUri();
      

Resolves the URI, which involves creation of an absolute CUri object from a given reference URI.

The screen output from this example is:

Parsing a URI

       
        
       
       void CExampleInetProtUtil::ParseUri();
      

Parses the URI into its components (as given in RFC2396 ). The five URI components are:

  • scheme

  • authority

  • path

  • query

  • fragment.

The screen output from this example is:

Validating a URI

       
        
       
       void CExampleInetProtUtil::ValidateUriComponents();
      

Validates a given URI. This function is usually used for URIs with SIP as the scheme.

The screen output from this example is:

Extracting URI components

       
        
       
       void CExampleInetProtUtil::ExtractUriComponents();
      

Extracts URI components from the given URI.

The screen output from this example is:

Retrieving a filename from a URI

       
        
       
       void CExampleInetProtUtil::RetrieveFileName();
      

Extracts the actual physical location of the file from its URI.

The screen output from this example is:

Adding and removing delimiters from a URI

       
        
       
       void CExampleInetProtUtil::ModifyDelimiter();
      

Adds the delimiters to and removes the delimiters from a URI. Before doing this ensure that:

  • the delimiter is set using SetDelimiter()

  • the URI has already been parsed.

The screen output from this example is:

Removing whitespace from a URI

       
        
       
       void CExampleInetProtUtil::WhiteSpaceRemover();
      

Removes the whitespace from the given URI and returns the number of white spaces that were removed.

The screen output from this example is:

Escape encoding and decoding a URI

       
        
       
       void CExampleInetProtUtil::EscapeEncodeDecode();
      

Escape encodes the characters in a given URI as escape triplets and decodes it to the original one.

The screen output from this example is: