2 #ifndef JAWS_PARSE_HEADERS_H
3 #define JAWS_PARSE_HEADERS_H
5 #include "JAWS/Export.h"
6 #include "ace/Singleton.h"
8 #if !defined (ACE_LACKS_PRAGMA_ONCE)
10 #endif /* ACE_LACKS_PRAGMA_ONCE */
12 #include "ace/Message_Block.h"
13 #include "ace/Synch_Traits.h"
17 class JAWS_Export JAWS_Header_Info
23 int end_of_line () const;
24 void end_of_line (int flag
);
26 const char *last_header_name () const;
28 int last_header_length () const;
29 void last_header_length (int len
);
31 const JAWS_Header_Data
* last_header_data () const;
35 void append_last_header_value (char c
);
36 int append_last_header_value ();
37 void append_last_header_value (const char *begin
, const char *end
);
38 void reduce_last_header_value ();
40 void create_next_header_value (char *ht
);
41 // This will insert last_header_data into the table if it is not
42 // null. Then, it will create a new header_data node and populate
43 // it. If ht is null, last_header_data is not inserted.
45 void finish_last_header_value ();
46 // This will insert last_header_data into the table if it is not
49 int end_of_headers () const;
50 void end_of_headers (int flag
);
55 JAWS_Headers
*table ();
60 STATUS_CODE_NO_MEMORY
,
66 MAX_HEADER_LENGTH
= 8192
68 // Note that RFC 822 does not mention the maximum length of a header
69 // line. So in theory, there is no maximum length.
70 // In Apache, they assume that each header line should not exceed
71 // 8K. Who am I to disagree?
79 JAWS_Header_Data
*last_header_data_
;
81 int last_header_length_
;
84 char header_buf_
[MAX_HEADER_LENGTH
];
88 class JAWS_Export JAWS_Parse_Headers
91 int parse_headers (JAWS_Header_Info
*info
, ACE_Message_Block
&mb
);
92 // Return 0 means need more data, and call it again.
93 // Return 1 means all done or error.
95 int parse_header_name (JAWS_Header_Info
*info
, ACE_Message_Block
&mb
);
96 // Return 0 means reiterate on remaining input.
97 // Return 1 means input has ended (either because it ended
98 // prematurely, or that there are no more headers).
100 int parse_header_value (JAWS_Header_Info
*info
, ACE_Message_Block
&mb
);
101 // Return 0 means reiterate on remaining input.
102 // Return 1 means input has ended or that an error has occurred.
104 char * skipset (const char *set
, char *start
, char *end
);
105 // Scans from start to end for characters that match skip set.
106 // Returns pointer to first location between start and end of a
107 // character that is in the skip set.
109 char * skipcset (const char *set
, char *start
, char *end
);
110 // Scans from start to end for characters that match skip set.
111 // Returns pointer to first location between start and end of a
112 // character that is *not* in the skip set.
115 typedef ACE_Singleton
<JAWS_Parse_Headers
, ACE_SYNCH_MUTEX
> JAWS_Parse_Headers_Singleton
;
117 #endif /* !defined (JAWS_PARSE_HEADERS_H) */