summaryrefslogtreecommitdiff
path: root/apps/JAWS/server/HTTP_Helpers.h
blob: c5c30f226a3a26c162b07b2cd5d2a30cab644341 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/* -*- c++ -*- */
// Hey, Emacs!  This is a C++ file!
// $Id$

// ============================================================================
//
// = LIBRARY
//    apps
// 
// = FILENAME
//    HTTP_Helpers.h
//
// = AUTHOR
//    James, please add the appropriate attribution here.
// 
// ============================================================================

#if !defined (HTTP_HELPERS_H)
#define HTTP_HELPERS_H

#include "ace/Synch.h"

class HTTP_Helper
// Static functions to enhance the lives of HTTP programmers everywhere.
{
public:

  // Convert and HTTP-date into a time_t
  static time_t HTTP_mktime (const char *httpdate);

  // Create today's date
  static const char *HTTP_date (char *const date_string, int date_length);

  static int HTTP_month (const char *month);
  static const char *HTTP_month (int month);

  static char *HTTP_decode_string (char *path);

  static char *HTTP_decode_base64 (char *data);
  static char *HTTP_encode_base64 (char *data);

private:

  static int fixyear (int year);

private:
  static const char *const months_[12];
  static char const *alphabet_;

#if !defined (ACE_HAS_REENTRANT_LIBC)
#if defined (ACE_HAS_THREADS)  
  static ACE_Thread_Mutex mutex_;
#endif /* ACE_HAS_THREADS */
#endif /* NOT ACE_HAS_REENTRANT_LIBC */

};

// Design around the Singleton pattern

class HTTP_Status_Code
  // = TITLE
  //    Simplify interface to HTTP_types:
  //     -> type(path) returns the type of the path matched by extension.
  //     -> app(path) returns the app for the path matched by extension.
  //
  // = DESCRIPTION
  //     Design around the Singleton pattern
{
public:
  static const char **instance(void);
  // Singleton access point.

  enum STATUS_CODE 
  {
    STATUS_OK = 200,
    STATUS_CREATED = 201,
    STATUS_ACCEPTED = 202,
    STATUS_NO_CONTENT = 204,
    STATUS_MOVED_PERMANENTLY = 301,
    STATUS_MOVED_TEMPORARILY = 302,
    STATUS_NOT_MODIFIED = 304,
    STATUS_BAD_REQUEST = 400,
    STATUS_UNAUTHORIZED = 401,
    STATUS_FORBIDDEN = 403,
    STATUS_NOT_FOUND = 404,
    STATUS_INTERNAL_SERVER_ERROR = 500,
    STATUS_NOT_IMPLEMENTED = 501,
    STATUS_BAD_GATEWAY = 502,
    STATUS_SERVICE_UNAVAILABLE = 503,
    STATUS_INSUFFICIENT_DATA = 399
  };

  enum 
  {
    MAX_STATUS_CODE = 599
  };

private:
  // James, please add comments.
  static const char *Reason[MAX_STATUS_CODE + 1];
  static int instance_;
  static ACE_SYNCH_MUTEX lock_;
};

#endif /* HTTP_HELPERS_H */