Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / ACE / apps / JAWS / server / HTTP_Helpers.h
blobbb8e0ad6a89f85da4fd52ce890fb497cd735e286
1 /* -*- c++ -*- */
3 //=============================================================================
4 /**
5 * @file HTTP_Helpers.h
7 * @author James Hu
8 */
9 //=============================================================================
12 #ifndef HTTP_HELPERS_H
13 #define HTTP_HELPERS_H
15 #include "ace/Synch_Traits.h"
16 #include "ace/Thread_Mutex.h"
18 #if !defined (ACE_LACKS_PRAGMA_ONCE)
19 # pragma once
20 #endif /* ACE_LACKS_PRAGMA_ONCE */
22 /**
23 * @class HTTP_Helper
24 Static functions to enhance the lives of HTTP programmers everywhere.
26 class HTTP_Helper
28 public:
29 // Convert and HTTP-date into a time_t
30 static time_t HTTP_mktime (const char *httpdate);
32 // Create today's date
33 static const char *HTTP_date ();
34 static const char *HTTP_date (char *s);
36 // Month conversions (ascii <--> numeric)
37 static int HTTP_month (const char *month);
38 static const char *HTTP_month (int month);
40 static char *HTTP_decode_string (char *path);
42 // Encode/Decode base64 stuff (weak security model)
43 static char *HTTP_decode_base64 (char *data);
44 static char *HTTP_encode_base64 (char *data);
46 private:
47 static int fixyear (int year);
49 private:
50 static const char *const months_[12];
51 static char const *alphabet_;
53 /// Use this sometimes (e.g. HTTP_date)
54 static char *date_string_;
55 static ACE_SYNCH_MUTEX mutex_;
58 // Design around the Singleton pattern
60 /**
61 * @class HTTP_Status_Code
63 * @brief Go from numeric status codes to descriptive strings.
65 * Design around the Singleton pattern
67 class HTTP_Status_Code
69 public:
70 /// Singleton access point.
71 static const char **instance ();
73 enum STATUS_CODE
75 STATUS_OK = 200,
76 STATUS_CREATED = 201,
77 STATUS_ACCEPTED = 202,
78 STATUS_NO_CONTENT = 204,
79 STATUS_MOVED_PERMANENTLY = 301,
80 STATUS_MOVED_TEMPORARILY = 302,
81 STATUS_NOT_MODIFIED = 304,
82 STATUS_BAD_REQUEST = 400,
83 STATUS_UNAUTHORIZED = 401,
84 STATUS_FORBIDDEN = 403,
85 STATUS_NOT_FOUND = 404,
86 STATUS_INTERNAL_SERVER_ERROR = 500,
87 STATUS_NOT_IMPLEMENTED = 501,
88 STATUS_BAD_GATEWAY = 502,
89 STATUS_SERVICE_UNAVAILABLE = 503,
90 STATUS_INSUFFICIENT_DATA = 399
93 enum
95 MAX_STATUS_CODE = 599
98 private:
99 // Singleton pattern is afoot here.
100 static const char *Reason[MAX_STATUS_CODE + 1];
101 static int instance_;
102 static ACE_SYNCH_MUTEX lock_;
105 #endif /* HTTP_HELPERS_H */