summaryrefslogtreecommitdiff
path: root/apps/JAWS/server/HTTP_Request.h
blob: 018cf2878f63d392195b7aaa803e959b665a0b95 (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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
/* -*- c++ -*- */
// Hey, Emacs!  This is a C++ file!
// $Id$

#if !defined (HTTP_REQUEST_H)
#define HTTP_REQUEST_H

class ACE_Message_Block;

#include "ace/OS.h"
#include "JAWS/server/Parse_Headers.h"

class HTTP_Request 
{
public:
  HTTP_Request (void);
  // Default construction.

  ~HTTP_Request (void);
  // Destructor.

  int parse_request (ACE_Message_Block &mb);
  // parse an incoming request

  void parse_request_line (char * const request_line);
  // the first line of a request is the request line, which
  // is of the form: METHOD URI VERSION

  int init (char * const buffer, int buflen);
  // Initialize the request object.  This will parse
  // the buffer and prepare for the accessors.

public:
  // The Accessors

  const char * method (void) const;
  const char * uri (void) const;
  const char * version (void) const;
  const char * path (void) const;

  int cgi (void) const;
  const char * cgi_args (void) const;
  const char ** cgi_env (void) const;

  const char * query_string (void) const;
  const char * path_info (void) const;

  int type (void) const;

  const Headers & headers (void) const;
  const char * header_strings (int index) const;
  const char * header_values (int index) const;

  // These are accessors I didn't implement, or don't
  // remember implementing, anyway.
  char *data (void);
  int data_length (void);
  int content_length (void);

  int status (void);
  const char *status_string (void);

  void dump (void);
  // Dump the state of the request.

  enum
  {
    NO_TYPE = -1,
    GET = 0,
    HEAD,
    POST,
    PUT,
    NUM_METHOD_STRINGS
  };

  enum
  {
    DATE = 0,
    PRAGMA,
    AUTHORIZATION,
    FROM,
    IF_MODIFIED_SINCE,
    REFERRER,
    USER_AGENT,
    ALLOW,
    CONTENT_ENCODING,
    CONTENT_LENGTH,
    CONTENT_TYPE,
    EXPIRES,
    LAST_MODIFIED,
    NUM_HEADER_STRINGS
  };

private:
  // Private Accessors which can set values
  const char * method (const char *method_string);
  const char * uri (char *uri_string);
  const char * version (const char *version_string);
  const char * path (const char *uri_string);

  int cgi (char *uri_string);

  int type (const char *type_string);

private:
  int got_request_line (void) const;

private:
  int got_request_line_;
  Headers headers_;

  char *method_;
  char *uri_;
  char *version_;
  char *path_;

  int cgi_;
  char **cgi_env_;
  char *cgi_args_;

  char *query_string_;
  char *path_info_;

  const char * const * const header_strings_;
  static const char * const static_header_strings_[NUM_HEADER_STRINGS];

  const char * const * const method_strings_;
  static const char * const static_method_strings_[NUM_METHOD_STRINGS];

  char *data_;
  int datalen_;
  int content_length_;
  char *filename_;
  int status_;
  int type_;
};

#endif /* HTTP_REQUEST_H */