VBS HTTP Classes


Topics:

Overview
Enumerations
Data Structures
Functions


Overview

HTTP client/server constants and data structures shared between HTTP client and server applications.


Enumerations

enum { // HTTP methods enumeration
  vbHTTP_UNKNOWN = 0, // Used for internal processing
  
  // HTTP/1.0 Client/Server Methods
  vbsHTTP_GET,    // Retrieve whatever data is identified by the URI
  vbsHTTP_HEAD,   // Returns only HTTP headers and no document body 
  vbsHTTP_PUT,    // Store the data under the supplied URL
  vbsHTTP_DELETE, // Delete information corresponding to the given URL
  vbsHTTP_POST,   // Creates object linked to the specified object 
  vbsHTTP_LINK,   // Links an existing object to the specified object 
  vbsHTTP_UNLINK  // Removes link information from an object 
};

enum { // HTTP status codes enumeration
  vbsHTTP_STATUS_UNKNOWN = 0, // Used for internal processing
  
  // HTTP/1.0 Status Codes obtained from:
  // http://sifu.rindu.net/course/one/freesoft/CIE/RFC/1945/1.htm

  // 1xx: Informational - Not used, but reserved for future use.

  // 2xx: Success - The action was successfully received, understood,
  // and accepted. 
  vbsHTTP_STATUS_OK	   = 200,  // The request has succeeded.
  vbsHTTP_STATUS_CREATED   = 201,  // The request has been fulfilled
                                   // and resulted in a new resource
                                   // being created (Used with POST).
  vbsHTTP_STATUS_ACCEPTED  = 202,  // The request has been accepted for
                                   // processing, but the processing 
                                   // has not been completed. 
  vbsHTTP_STATUS_NO_CONTENT = 204, // The server has fulfilled the
                                   // request but there is no new
                                   // information to send back.

  // 3xx: Redirection - Further action must be taken in order to 
  // complete the request.
  vbsHTTP_STATUS_MULTIPLE_CHOICES  = 300, // The requested resource is
                                          // available at one or more
                                          // locations. 
  vbsHTTP_STATUS_MOVED_PERMANENTLY = 301, // The requested resource has 
                                          // been assigned a new
                                          // permanent URL and
                                          // any future references to
                                          // this resource should
                                          // be done using that URL.
  vbsHTTP_STATUS_MOVED_TEMPORARILY = 302, // The requested resource 
                                          // resides temporarily under
                                          // a different URL.
  vbsHTTP_STATUS_NOT_MODIFIED      = 304, // Returned if the client has
                                          // performed a conditional
                                          // GET request and access is
                                          // allowed, but the document 
                                          // has not been modified
                                          // since the date and time
                                          // specified in the 
                                          // If-Modified-Since 
                                          // field.

  // 4xx: Client Error - The request contains bad syntax or cannot be
  // fulfilled.
  vbsHTTP_STATUS_BAD_REQUEST       = 400, // The request could not be
                                          // understood by the server 
                                          // due to malformed syntax.
  vbsHTTP_STATUS_UNAUTHORIZED      = 401, // The request requires user
                                          // authentication. The 
                                          // response must include
                                          // a WWW-Authenticate header
                                          // field containing a 
                                          // challenge applicable
                                          // to the requested
                                          // resource. 
  vbsHTTP_STATUS_FORBIDDEN         = 403, // The server understood the
                                          // request, but is refusing
                                          // to fulfill it.
                                          // Authorization will not
                                          // help and the request
                                          // should not be repeated.
  vbsHTTP_STATUS_NOT_FOUND         = 404, // The server has not found
                                          // anything matching the
                                          // Request-URI.

  // 5xx: Server Error - The server failed to fulfill an apparently 
  // valid request.
  vbsHTTP_STATUS_INTERNAL          = 500, // The server encountered an
                                          // unexpected condition which
                                          // prevented it from 
                                          // fulfilling the request.
  vbsHTTP_STATUS_NOT_IMPLEMENTED   = 501, // The server does not
                                          // support the
                                          // functionality required to 
                                          // fulfill the request.
  vbsHTTP_STATUS_BAD_GATEWAY       = 502, // The server, while acting 
                                          // as a gateway or proxy, 
                                          // received an invalid 
                                          // response from the
                                          // upstream server it 
                                          // accessed in attempting
                                          // to fulfill the request.
  vbsHTTP_STATUS_UNAVAILABLE       = 503  // The server is currently
                                          // unable to handle the
                                          // request due to a
                                          // temporary overloading or
                                          // maintenance of the server.
};


Data Structures

struct vbsNetscapeCookie
{
  // Cookie information
  vbString expires;
  vbString domain;
  vbString path;
  vbString host;
  vbString name;
  vbString value;
  int secure;
};

struct vbsHTTPHeader {
  // HTTP client/server header information
  vbString http_header;            // Unchanged or complete HTTP header
  vbString authentication_scheme;  // Authentication scheme used
  vbString realm;                  // Authentication realm 
  vbString current_server;         // Server type
  vbString location;               // Document location
  vbString http_last_modified;     // Date document was last modified
  vbString date;                   // Today's date
  vbString http_expires;           // Date this document expires 
  vbString file_extension;         // Document's file extension
  vbString content_type;           // Content type
  vbString mime_type;              // MIME type
  vbString etag;                   // Associated Entity tag 
  vbString pragma;                 // Implementation specific 
  vbString cache_control;          // Cache control parameters
  vbString content_encoding;       // Content encoding used
  float http_version;              // HTTP version
  int http_status;                 // Document/Client/Server status
  int authentication_needed;       // True if authentication is needed
  int not_found;                   // True if the document is not found
  int keep_alive;                  // True if connection is persistent
  int timeout;                     // Time out value
  int max_conns;                   // Maximum number of connections
  int length;                      // Document length
  int no_cache;                    // True if not using cached copies
  int accept_ranges;               // True if ranges are accepted

  // Netscape cookie infomation
  vbString auth_cookie; // Authentication cookie
  int use_cookies;      // True if using cookies
  vbQueue<vbsNetscapeCookie> netscape_cookies; // List of cookies
};


Functions

const char *vbsHTTPMethodMessage(int method) - Standalone function that returns a null terminated string corresponding to the specified connection method. The "method" variable must correspond to the one of the integer constants defined in the HTTP methods enumeration.

const char *vbsHTTPStatusCodeMessage(int status) - Standalone function that returns a null terminated string corresponding to the specified HTTP status message. The "status" variable must correspond to the one of the integer constants defined in the HTTP status code enumeration.


End Of Document