2010-10-27 18:03:31 +04:00
|
|
|
/*
|
|
|
|
* Copyright 2010 Haiku Inc. All rights reserved.
|
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
|
|
|
#ifndef _B_HTTP_HEADERS_H_
|
|
|
|
#define _B_HTTP_HEADERS_H_
|
|
|
|
|
|
|
|
|
|
|
|
#include <List.h>
|
|
|
|
#include <String.h>
|
|
|
|
|
|
|
|
|
|
|
|
class BHttpHeader {
|
|
|
|
public:
|
|
|
|
BHttpHeader();
|
|
|
|
BHttpHeader(const char* string);
|
2015-09-05 16:33:32 +03:00
|
|
|
BHttpHeader(const char* name,
|
2010-10-27 18:03:31 +04:00
|
|
|
const char* value);
|
|
|
|
BHttpHeader(const BHttpHeader& copy);
|
2015-09-05 16:33:32 +03:00
|
|
|
|
2010-10-27 18:03:31 +04:00
|
|
|
// Header data modification
|
|
|
|
void SetName(const char* name);
|
|
|
|
void SetValue(const char* value);
|
|
|
|
bool SetHeader(const char* string);
|
2015-09-05 16:33:32 +03:00
|
|
|
|
2010-10-27 18:03:31 +04:00
|
|
|
// Header data access
|
|
|
|
const char* Name() const;
|
2015-09-05 16:33:32 +03:00
|
|
|
const char* Value() const;
|
|
|
|
const char* Header() const;
|
|
|
|
|
2010-10-27 18:03:31 +04:00
|
|
|
// Header data test
|
|
|
|
bool NameIs(const char* name) const;
|
2015-09-05 16:33:32 +03:00
|
|
|
|
2010-10-27 18:03:31 +04:00
|
|
|
// Overloaded members
|
|
|
|
BHttpHeader& operator=(const BHttpHeader& other);
|
|
|
|
|
|
|
|
private:
|
|
|
|
BString fName;
|
|
|
|
BString fValue;
|
2015-09-05 16:33:32 +03:00
|
|
|
|
2010-10-27 18:03:31 +04:00
|
|
|
mutable BString fRawHeader;
|
|
|
|
mutable bool fRawHeaderValid;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class BHttpHeaders {
|
|
|
|
public:
|
|
|
|
BHttpHeaders();
|
|
|
|
BHttpHeaders(const BHttpHeaders& copy);
|
|
|
|
~BHttpHeaders();
|
2015-09-05 16:33:32 +03:00
|
|
|
|
2010-10-27 18:03:31 +04:00
|
|
|
// Header list access
|
|
|
|
const char* HeaderValue(const char* name) const;
|
|
|
|
BHttpHeader& HeaderAt(int32 index) const;
|
2015-09-05 16:33:32 +03:00
|
|
|
|
2010-10-27 18:03:31 +04:00
|
|
|
// Header count
|
|
|
|
int32 CountHeaders() const;
|
2015-09-05 16:33:32 +03:00
|
|
|
|
2010-10-27 18:03:31 +04:00
|
|
|
// Header list tests
|
|
|
|
int32 HasHeader(const char* name) const;
|
2015-09-05 16:33:32 +03:00
|
|
|
|
2010-10-27 18:03:31 +04:00
|
|
|
// Header add or replacement
|
|
|
|
bool AddHeader(const char* line);
|
2015-09-05 16:33:32 +03:00
|
|
|
bool AddHeader(const char* name,
|
2010-10-27 18:03:31 +04:00
|
|
|
const char* value);
|
|
|
|
bool AddHeader(const char* name,
|
|
|
|
int32 value);
|
2015-09-05 16:33:32 +03:00
|
|
|
|
2010-10-27 18:03:31 +04:00
|
|
|
// Header deletion
|
2015-09-05 16:33:32 +03:00
|
|
|
void Clear();
|
|
|
|
|
2010-10-27 18:03:31 +04:00
|
|
|
// Overloaded operators
|
|
|
|
BHttpHeaders& operator=(const BHttpHeaders& other);
|
|
|
|
BHttpHeader& operator[](int32 index) const;
|
|
|
|
const char* operator[](const char* name) const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
void _EraseData();
|
2014-06-06 00:01:40 +04:00
|
|
|
bool _AddOrDeleteHeader(BHttpHeader* header);
|
2015-09-05 16:33:32 +03:00
|
|
|
|
2010-10-27 18:03:31 +04:00
|
|
|
private:
|
|
|
|
BList fHeaderList;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // _B_HTTP_HEADERS_H_
|