mirror of
https://gitee.com/acl-dev/acl.git
synced 2024-12-02 11:57:43 +08:00
http_header::add_entry: add param replace for checking if replade the old exist value
This commit is contained in:
parent
05b485b6c4
commit
612bced38d
@ -70,9 +70,11 @@ public:
|
||||
* 向 HTTP 头中添加字段
|
||||
* @param name {const char*} 字段名,非空指针
|
||||
* @param value {const char*} 字段值,非空指针
|
||||
* @param replace {bool} 如果存在重复项时是否自动覆盖旧数据
|
||||
* @return {http_header&} 返回本对象的引用,便于用户连续操作
|
||||
*/
|
||||
http_header& add_entry(const char* name, const char* value);
|
||||
http_header& add_entry(const char* name, const char* value,
|
||||
bool replace = true);
|
||||
|
||||
/**
|
||||
* 设置 HTTP 头中的 Content-Length 字段
|
||||
|
@ -122,11 +122,14 @@ http_header& http_header::set_request_mode(bool onoff)
|
||||
return *this;
|
||||
}
|
||||
|
||||
http_header& http_header::add_entry(const char* name, const char* value)
|
||||
http_header& http_header::add_entry(const char* name, const char* value,
|
||||
bool replace /* = true */)
|
||||
{
|
||||
if (name == NULL || *name == 0 || value == NULL || *value == 0)
|
||||
return *this;
|
||||
|
||||
if (replace)
|
||||
{
|
||||
std::list<HTTP_HDR_ENTRY*>::iterator it = entries_.begin();
|
||||
for (; it != entries_.end(); ++it)
|
||||
{
|
||||
@ -136,6 +139,7 @@ http_header& http_header::add_entry(const char* name, const char* value)
|
||||
return *this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
HTTP_HDR_ENTRY* entry = (HTTP_HDR_ENTRY*)
|
||||
dbuf_->dbuf_calloc(sizeof(HTTP_HDR_ENTRY));
|
||||
|
Loading…
Reference in New Issue
Block a user