Fix FreeBSD build.
[haiku.git] / headers / os / net / HttpHeaders.h
blob0b22845b72424b9d3a096217a80652c57a08b172
1 /*
2 * Copyright 2010 Haiku Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
4 */
5 #ifndef _B_HTTP_HEADERS_H_
6 #define _B_HTTP_HEADERS_H_
9 #include <List.h>
10 #include <Message.h>
11 #include <String.h>
14 class BHttpHeader {
15 public:
16 BHttpHeader();
17 BHttpHeader(const char* string);
18 BHttpHeader(const char* name,
19 const char* value);
20 BHttpHeader(const BHttpHeader& copy);
22 // Header data modification
23 void SetName(const char* name);
24 void SetValue(const char* value);
25 bool SetHeader(const char* string);
27 // Header data access
28 const char* Name() const;
29 const char* Value() const;
30 const char* Header() const;
32 // Header data test
33 bool NameIs(const char* name) const;
35 // Overloaded members
36 BHttpHeader& operator=(const BHttpHeader& other);
38 private:
39 BString fName;
40 BString fValue;
42 mutable BString fRawHeader;
43 mutable bool fRawHeaderValid;
47 class BHttpHeaders {
48 public:
49 BHttpHeaders();
50 BHttpHeaders(const BHttpHeaders& copy);
51 ~BHttpHeaders();
53 // Header list access
54 const char* HeaderValue(const char* name) const;
55 BHttpHeader& HeaderAt(int32 index) const;
57 // Header count
58 int32 CountHeaders() const;
60 // Header list tests
61 int32 HasHeader(const char* name) const;
63 // Header add or replacement
64 bool AddHeader(const char* line);
65 bool AddHeader(const char* name,
66 const char* value);
67 bool AddHeader(const char* name,
68 int32 value);
70 // Archiving
71 void PopulateFromArchive(BMessage*);
72 void Archive(BMessage*) const;
74 // Header deletion
75 void Clear();
77 // Overloaded operators
78 BHttpHeaders& operator=(const BHttpHeaders& other);
79 BHttpHeader& operator[](int32 index) const;
80 const char* operator[](const char* name) const;
82 private:
83 void _EraseData();
84 bool _AddOrDeleteHeader(BHttpHeader* header);
86 private:
87 BList fHeaderList;
90 #endif // _B_HTTP_HEADERS_H_