2 * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved.
4 * The contents of this file constitute Original Code as defined in and are
5 * subject to the Apple Public Source License Version 1.2 (the 'License').
6 * You may not use this file except in compliance with the License. Please obtain
7 * a copy of the License at http://www.apple.com/publicsource and read it before
10 * This Original Code and all software distributed under the License are
11 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS
12 * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT
13 * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the
15 * specific language governing rights and limitations under the License.
20 // headermap - represent Internet-standard headers
22 //@@@ Handle duplicate entries.
23 //@@@ Be flexible: think HTTP (append with commas) vs. RFC822 (multiple Received: headers etc.)
39 static const int maxKeyLength
= 80;
40 typedef std::map
<std::string
, std::string
> Map
;
43 virtual ~HeaderMap() { }
45 virtual void merge(std::string key
, std::string
&old
, std::string newValue
);
47 void add(const char *key
, const char *value
);
48 void add(const char *line
); // Key: value
49 void remove(const char *key
);
51 const char *find(const char *key
, const char *def
= NULL
) const;
52 std::string
&operator [] (const char *key
);
54 typedef Map::const_iterator ConstIterator
;
55 ConstIterator
begin() const { return mMap
.begin(); }
56 ConstIterator
end() const { return mMap
.end(); }
58 typedef Map::const_iterator Iterator
;
59 Iterator
begin() { return mMap
.begin(); }
60 Iterator
end() { return mMap
.end(); }
62 std::string
collect(const char *lineEnding
= "\r\n") const;
63 size_t collectLength(const char *lineEnding
= "\r\n") const;
67 // In-place case canonicalization of header keys
70 CanonicalKey(const char *key
, char end
= '\0');
71 operator const char *() const { return mValue
; }
72 operator std::string () const { return mValue
; }
74 char mValue
[maxKeyLength
];
77 void add(const CanonicalKey
&key
, const char *value
);
80 Map mMap
; // map of key: value pairs
84 } // end namespace Security