HTTP_Handler.h

Go to the documentation of this file.
00001 
00002 /* -*- C++ -*- */
00003 
00004 //=============================================================================
00005 /**
00006  *  @file    HTTP_Handler.h
00007  *
00008  *  $Id: HTTP_Handler.h 79237 2007-08-07 09:48:21Z johnnyw $
00009  *
00010  *   HTTP_Handler is a base class for HTTP_Reader and
00011  *   HTTP_Writer which are created in response to calls to
00012  *   read/write, as appropriate
00013  */
00014 //=============================================================================
00015 
00016 
00017 #ifndef TAO_HTTP_HANDLER_H
00018 #define TAO_HTTP_HANDLER_H
00019 
00020 #include /**/ "tao/TAO_Export.h"
00021 
00022 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00023 # pragma once
00024 #endif /* ACE_LACKS_PRAGMA_ONCE */
00025 
00026 #include "tao/orbconf.h"
00027 
00028 #if (TAO_HAS_HTTP_PARSER == 1)
00029 
00030 #include "ace/SOCK_Stream.h"
00031 #include "ace/Svc_Handler.h"
00032 #include "ace/Message_Block.h"
00033 #include "tao/Versioned_Namespace.h"
00034 
00035 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00036 
00037 /**
00038  * @class TAO_HTTP_Handler
00039  * class to retrieve data via HTTP
00040  */
00041 class TAO_Export TAO_HTTP_Handler : public ACE_Svc_Handler <ACE_SOCK_STREAM, ACE_NULL_SYNCH>
00042 {
00043 public:
00044   /// Null constructor, insures that it works properly with Connector
00045   TAO_HTTP_Handler (void);
00046 
00047   /// Always use this constructor to make HTTP_Handlers
00048   TAO_HTTP_Handler (ACE_Message_Block *mb,
00049                     ACE_TCHAR *filename);
00050 
00051   /// returns the number of bytes read/written in the last operation.
00052   size_t byte_count (void) const;
00053 
00054   /// Activate this instance of the <HTTP_Handler>
00055   virtual int open (void * = 0);
00056 
00057   /// Close down the Blob
00058   virtual int close (u_long flags = 0);
00059 
00060   ~TAO_HTTP_Handler (void);
00061 
00062 protected:
00063   virtual int send_request (void);
00064   virtual int receive_reply (void);
00065 
00066   ACE_Message_Block *mb_;
00067   ACE_TCHAR *filename_;
00068   size_t bytecount_;
00069   enum
00070   {
00071     /// The handler assumes that the first 2048 bytes of a server response
00072     /// contains the header
00073     MAX_HEADER_SIZE = 2048,
00074 
00075     /// set the MAX_TRANSMISSION_UNIT (MTU) = BUFSIZ as defined by OS
00076     MTU = BUFSIZ
00077   };
00078 };
00079 
00080 class TAO_HTTP_Reader : public TAO_HTTP_Handler
00081 {
00082 public:
00083   TAO_HTTP_Reader (ACE_Message_Block *mb,
00084                    ACE_TCHAR *filename,
00085                    const char *request_prefix = "GET",
00086                    const char *request_suffix = "HTTP/1.0\r\nAccept: HTTP/1.0\r\n\r\n");
00087 
00088 private:
00089   //NOTE: these functions return -1 on error
00090   int send_request (void);
00091   int receive_reply (void);
00092   const char *request_prefix_;
00093   const char *request_suffix_;
00094 };
00095 
00096 TAO_END_VERSIONED_NAMESPACE_DECL
00097 
00098 #endif /* TAO_HAS_HTTP_PARSER == 1 */
00099 
00100 #endif /* TAO_HTTP_HANDLER_H */

Generated on Tue Feb 2 17:37:52 2010 for TAO by  doxygen 1.4.7