3 //=============================================================================
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)
20 #endif /* ACE_LACKS_PRAGMA_ONCE */
24 Static functions to enhance the lives of HTTP programmers everywhere.
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
);
47 static int fixyear (int year
);
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
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
70 /// Singleton access point.
71 static const char **instance ();
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
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 */