summaryrefslogtreecommitdiff
path: root/apps/JAWS2/HTTPU/http_base.h
blob: 5f5486f888ddaf63779dd4434b9f85deb1a48b29 (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
// $Id$

#ifndef HTTPU_HTTP_BASE_H
#define HTTPU_HTTP_BASE_H

#include "ace/Message_Block.h"

#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */

#include "JAWS/Parse_Headers.h"
#include "HTTPU/http_export.h"
#include "HTTPU/http_status.h"
#include "HTTPU/http_headers.h"

class HTTPU_Export HTTP_Base : public HTTP_SCode_Base
{
public:

  HTTP_Base (void);
  virtual ~HTTP_Base (void);

  virtual int receive (ACE_Message_Block &mb);
  virtual int deliver (ACE_Message_Block &mb);

  virtual int receive_payload (ACE_Message_Block &mb);
  virtual int receive_payload (ACE_Message_Block &mb, long length);

  const char * payload (void);
  unsigned long payload_size (void);

  int status (void) const;
  const char *line (void) const;
  HTTP_Headers *http_headers (void);
  JAWS_Headers *headers (void);

  int build_headers (JAWS_Headers *new_headers);
  // takes a set of new headers that will replace existing headers or
  // be added to the header list if there is no corresponding one to replace.

  void dump (void);

protected:

  virtual void parse_line (void) = 0;
  // Hook into the receive function to do specialized parsing of initial line.
  // Sets the status_ variable.

  virtual int espouse_line (void) = 0;
  // Hook into the deliver function to do specialized initial line creation.
  // Returns 0 for success and -1 for failure.

  int deliver_header_name (JAWS_Header_Data *&data);
  // Returns the next deliver state

  int deliver_header_value (JAWS_Header_Data *&data);
  // Returns the next deliver state

  virtual int extract_line (ACE_Message_Block &mb);
  // The first line of a request or a response.
  // Return 0 if more data needed.
  // Return 1 if line successfully parsed.

protected:

  int status_;
  char *line_;
  int deliver_state_;
  int no_headers_;
  HTTP_Headers info_;
  JAWS_Header_Table_Iterator iter_;
  ACE_Message_Block *mb_;
  ACE_Message_Block payload_;

};


#if defined (ACE_HAS_INLINED_OSCALLS)
#   if defined (ACE_INLINE)
#     undef ACE_INLINE
#   endif /* ACE_INLINE */
#   define ACE_INLINE inline
#   include "HTTPU/http_base.i"
# endif /* ACE_HAS_INLINED_OSCALLS */

#endif /* !defined (HTTPU_HTTP_BASE_H) */