Merge pull request #2317 from jwillemsen/jwi-deleteop
[ACE_TAO.git] / ACE / apps / JAWS / clients / Caching / http_handler.h
blob574e2a228314ae3116fa2c6098b50c50edad2b36
1 /* -*- c++ -*- */
3 //=============================================================================
4 /**
5 * @file http_handler.h
7 * @author James Hu
8 */
9 //=============================================================================
12 #include "ace/SOCK_Connector.h"
14 #if !defined (ACE_LACKS_PRAGMA_ONCE)
15 # pragma once
16 #endif /* ACE_LACKS_PRAGMA_ONCE */
18 #include "ace/Connector.h"
19 #include "ace/Svc_Handler.h"
21 /**
22 * @class HTTP_Handler
24 * @brief A simple HTTP protocol handler for clients.
26 * Checks to see if the requested file is already cached. If
27 * so, it says so. If not, the request is issued to the
28 * connection. The fetched file is cached.
30 class HTTP_Handler : public ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH>
32 public:
33 HTTP_Handler ();
34 HTTP_Handler (const char * path);
36 /// Open hook.
37 virtual int open (void *);
39 /// Entry points defined by the abstract Svc_Handler.
40 virtual int svc ();
42 /// Accessor to the file being fetched.
43 const char *filename () const;
45 private:
46 char request_[BUFSIZ];
47 size_t request_size_;
49 char filename_[BUFSIZ];
50 size_t response_size_;
53 /**
54 * @class HTTP_Connector
56 * @brief A simple HTTP connector.
58 * Creates an HTTP Handler based on the URL, and then delegates
59 * to to the SOCK_CONNECTOR. Adapter pattern.
61 class HTTP_Connector
63 public:
64 /// User entry point into the HTTP connector.
65 int connect (const char * url);
67 private:
68 /// Helper function.
69 int parseurl (const char *url,
70 char *host,
71 u_short *port,
72 char *path);
74 private:
75 /// Factory that actively establishes a connection with an HTTP
76 /// server.
77 ACE_Connector<HTTP_Handler, ACE_SOCK_CONNECTOR> connector_;