2 * Copyright (c) 2000-2002,2004 Apple Computer, Inc. All Rights Reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
26 // headermap - represent Internet-standard headers
28 //@@@ Handle duplicate entries.
29 //@@@ Be flexible: think HTTP (append with commas) vs. RFC822 (multiple Received: headers etc.)
45 static const int maxKeyLength
= 80;
46 typedef std::map
<std::string
, std::string
> Map
;
49 virtual ~HeaderMap() { }
51 virtual void merge(std::string key
, std::string
&old
, std::string newValue
);
53 void add(const char *key
, const char *value
);
54 void add(const char *line
); // Key: value
55 void remove(const char *key
);
57 const char *find(const char *key
, const char *def
= NULL
) const;
58 std::string
&operator [] (const char *key
);
60 typedef Map::const_iterator ConstIterator
;
61 ConstIterator
begin() const { return mMap
.begin(); }
62 ConstIterator
end() const { return mMap
.end(); }
64 typedef Map::const_iterator Iterator
;
65 Iterator
begin() { return mMap
.begin(); }
66 Iterator
end() { return mMap
.end(); }
68 std::string
collect(const char *lineEnding
= "\r\n") const;
69 size_t collectLength(const char *lineEnding
= "\r\n") const;
73 // In-place case canonicalization of header keys
76 CanonicalKey(const char *key
, char end
= '\0');
77 operator const char *() const { return mValue
; }
78 operator std::string () const { return mValue
; }
80 char mValue
[maxKeyLength
];
83 void add(const CanonicalKey
&key
, const char *value
);
86 Map mMap
; // map of key: value pairs
90 } // end namespace Security
93 #endif /* _H_HEADERMAP */