Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / ACE / apps / JAWS / clients / Blobby / Blob_Handler.h
blob9d3d5114702c4b1dfd3cc60086541c2a5c2ccf76
1 /* -*- C++ -*- */
3 //=============================================================================
4 /**
5 * @file Blob_Handler.h
7 * ACE_Blob_Handler is a base class for ACE_Blob_Reader and
8 * ACE_Blob_Writer which are created in response to calls to
9 * read/write, as appropriate
11 * @author Prashant Jain and Sumedh Mungee
13 //=============================================================================
16 #ifndef ACE_BLOB_HANDLER_H
17 #define ACE_BLOB_HANDLER_H
19 #include "ace/config-all.h"
21 #if !defined (ACE_LACKS_PRAGMA_ONCE)
22 # pragma once
23 #endif /* ACE_LACKS_PRAGMA_ONCE */
25 #include "ace/SOCK_Stream.h"
26 #include "ace/Svc_Handler.h"
27 #include "ace/Message_Block.h"
29 /**
30 * @class ACE_Blob_Handler
32 * @brief Blob is intended to provide application API to
33 * classes that wish to do network i/o at a very
34 * high level of abstraction.
35 * = This class provides the ability to retrieve data from
36 * the network, of specified length and offset, and potentially
37 * use any protocol "under the hood" to do so. It currently
38 * uses HTTP. See Blob_Handler also.
40 class ACE_Blob_Handler : public ACE_Svc_Handler <ACE_SOCK_STREAM, ACE_NULL_SYNCH>
42 public:
43 /// Null constructor, insures that it works properly with Connector
44 ACE_Blob_Handler ();
46 /// Always use this constructor to make Blob_Handlers
47 ACE_Blob_Handler (ACE_Message_Block *mb,
48 size_t length,
49 size_t offset,
50 ACE_TCHAR *filename);
52 /// returns the number of bytes read/written in the last operation.
53 int byte_count ();
55 /// Activate this instance of the <ACE_Blob_Handler>
56 virtual int open (void * = 0);
58 /// Close down the Blob
59 virtual int close (u_long flags = 0);
61 ~ACE_Blob_Handler ();
63 protected:
64 virtual int send_request ();
65 virtual int receive_reply ();
67 ACE_Message_Block *mb_;
68 size_t length_;
69 size_t offset_;
70 ACE_TCHAR *filename_;
71 int bytecount_;
72 enum
74 MAX_HEADER_SIZE = 2048
75 // The handler assumes that the first 2048 bytes of a server response
76 // contains the header
80 class ACE_Blob_Reader : public ACE_Blob_Handler
82 public:
83 ACE_Blob_Reader (ACE_Message_Block *mb,
84 size_t length,
85 size_t offset,
86 ACE_TCHAR *filename,
87 const char *request_prefix = "GET",
88 const char *request_suffix = "HTTP/1.0\r\n\r\n");
90 private:
91 int send_request ();
92 int receive_reply ();
93 const char *request_prefix_;
94 const char *request_suffix_;
97 class ACE_Blob_Writer : public ACE_Blob_Handler
99 public:
100 ACE_Blob_Writer (ACE_Message_Block *mb,
101 size_t length,
102 size_t offset,
103 ACE_TCHAR *filename,
104 const char *request_prefix = "PUT",
105 const char *request_suffix = "HTTP/1.0\nContent-length:");
107 private:
108 int send_request ();
109 int receive_reply ();
110 const char *request_prefix_;
111 const char *request_suffix_;
114 #endif /* ACE_BLOB_HANDLER_H */