Merge pull request #2303 from jwillemsen/jwi-803
[ACE_TAO.git] / TAO / tao / HTTP_Handler.h
blob4baf60fb1d874958980049d086a6fc7da3b97530
2 /* -*- C++ -*- */
4 //=============================================================================
5 /**
6 * @file HTTP_Handler.h
8 * HTTP_Handler is a base class for HTTP_Reader and
9 * HTTP_Writer which are created in response to calls to
10 * read/write, as appropriate
12 //=============================================================================
15 #ifndef TAO_HTTP_HANDLER_H
16 #define TAO_HTTP_HANDLER_H
18 #include /**/ "tao/TAO_Export.h"
20 #if !defined (ACE_LACKS_PRAGMA_ONCE)
21 # pragma once
22 #endif /* ACE_LACKS_PRAGMA_ONCE */
24 #include "tao/orbconf.h"
26 #if (TAO_HAS_HTTP_PARSER == 1)
28 #include "ace/SOCK_Stream.h"
29 #include "ace/Svc_Handler.h"
30 #include "ace/Message_Block.h"
31 #include "tao/Versioned_Namespace.h"
33 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
35 /**
36 * @class TAO_HTTP_Handler
37 * class to retrieve data via HTTP
39 class TAO_Export TAO_HTTP_Handler : public ACE_Svc_Handler <ACE_SOCK_STREAM, ACE_NULL_SYNCH>
41 public:
42 /// Null constructor, insures that it works properly with Connector
43 TAO_HTTP_Handler ();
45 /// Always use this constructor to make HTTP_Handlers
46 TAO_HTTP_Handler (ACE_Message_Block *mb,
47 ACE_TCHAR *filename);
49 /// returns the number of bytes read/written in the last operation.
50 size_t byte_count () const;
52 /// Activate this instance of the <HTTP_Handler>
53 virtual int open (void * = 0);
55 /// Close down the Blob
56 virtual int close (u_long flags = 0);
58 ~TAO_HTTP_Handler ();
60 protected:
61 virtual int send_request ();
62 virtual int receive_reply ();
64 ACE_Message_Block *mb_;
65 ACE_TCHAR *filename_;
66 size_t bytecount_;
67 enum
69 /// The handler assumes that the first 2048 bytes of a server response
70 /// contains the header
71 MAX_HEADER_SIZE = 2048,
73 /// set the MAX_TRANSMISSION_UNIT (MTU) = BUFSIZ as defined by OS
74 MTU = BUFSIZ
78 class TAO_HTTP_Reader : public TAO_HTTP_Handler
80 public:
81 TAO_HTTP_Reader (ACE_Message_Block *mb,
82 ACE_TCHAR *filename,
83 const char *request_prefix = "GET",
84 const char *request_suffix = "HTTP/1.0\r\nAccept: HTTP/1.0\r\n\r\n");
86 private:
87 //NOTE: these functions return -1 on error
88 int send_request ();
89 int receive_reply ();
90 const char *request_prefix_;
91 const char *request_suffix_;
94 TAO_END_VERSIONED_NAMESPACE_DECL
96 #endif /* TAO_HAS_HTTP_PARSER == 1 */
98 #endif /* TAO_HTTP_HANDLER_H */