fastdo
0.6.8
|
代表HTTP头部 更多...
#include <http_misc.hpp>
类 | |
class | ContentDisposition |
Content-Disposition域 更多... | |
class | ContentType |
Content-Type域 更多... | |
class | HeaderField |
解析/描述头域字段的值 更多... | |
Public 成员函数 | |
Header () | |
构造函数0 更多... | |
Header (std::initializer_list< std::pair< winux::String, winux::Mixed > > list) | |
构造函数1 更多... | |
void | clear () |
清空 更多... | |
winux::String | toString (bool isAddCrlfAtEnd=true) const |
转为字符串,isAddCrlfAtEnd指示末尾是否添加\r\n 更多... | |
Header & | parse (winux::String const &headerStr) |
从"HeaderField: XXXXX"字符串解析头部,可重复调用,不会清空先前解析的结果,要清空请调用clear() 更多... | |
winux::String const & | operator[] (winux::String const &name) const |
winux::String & | operator[] (winux::String const &name) |
winux::StringArray | getHeaders (winux::String const &name) const |
取得所有指定name的field值 更多... | |
winux::String | getHeader (winux::String const &name, winux::String const &defval=winux::String()) const |
template<typename _Ty > | |
_Ty | getHeader (winux::String const &name, _Ty const &defval=_Ty()) const |
void | addHeader (winux::String const &name, winux::String const &value) |
添加头 更多... | |
void | setHeader (winux::String const &name, winux::String const &value) |
bool | hasHeader (winux::String const &name) const |
void | delHeader (winux::String const &name) |
template<typename _HeaderField > | |
bool | get (winux::String const &name, _HeaderField *field) const |
template<typename _HeaderField > | |
_HeaderField | get (winux::String const &name) const |
winux::StringWriter | operator() (winux::String const &name) |
设置headers,可以增加新头域 更多... | |
winux::StringWriter | operator() (winux::String const &name, int i) |
修改multiheaders,无法增加新头域 更多... | |
winux::String | getMultiHeader (winux::String const &name, int i, winux::String const &defval=winux::String()) const |
void | addMultiHeader (winux::String const &name, winux::String const &value) |
bool | hasMultiHeader (winux::String const &name) const |
void | delMultiHeader (int index) |
void | setResponseLine (winux::String const &responseLine, bool setStatus=true) |
设置响应行 格式: HttpVersion StatusCode StatusStr eg. HTTP/1.1 200 OK 更多... | |
void | setRequestLine (winux::String const &requestLine) |
设置请求行 格式: Method URL HttpVersion eg. GET /index.do HTTP/1.1 更多... | |
winux::String | getStatusLine (bool isAddCrlf=false) const |
取得状态行,isAddCrlf指示末尾是否添加‘回车换行’,默认不添加 更多... | |
winux::String const & | getMethod () const |
方法. For a request: required. 更多... | |
winux::String const & | getUrl () const |
URL. For a request: required. 更多... | |
winux::String const & | getStatusCode () const |
状态码. For a response: required. 更多... | |
winux::String const & | getStatusStr () const |
状态文本. For a response: Not required 更多... | |
winux::String const & | getVersion () const |
HTTP版本. 更多... | |
Header & | setMethod (winux::String const &method) |
方法. For a request: required. 更多... | |
Header & | setUrl (winux::String const &url) |
URL. For a request: required. 更多... | |
Header & | setStatusCode (winux::String const &statusCode) |
状态码. For a response: required. 更多... | |
Header & | setStatusStr (winux::String const &statusStr) |
状态文本. For a response: Not required 更多... | |
Header & | setVersion (winux::String const &version) |
HTTP版本. 更多... | |
bool | enumHeader (winux::String *name, winux::String *value) const |
枚举所有头域一遍,多次调用即可,当完成枚举后返回false。再次调用即可重新枚举。 更多... | |
http::Header::Header | ( | ) |
构造函数0
http::Header::Header | ( | std::initializer_list< std::pair< winux::String, winux::Mixed > > | list | ) |
构造函数1
void http::Header::addHeader | ( | winux::String const & | name, |
winux::String const & | value | ||
) |
添加头
如果name已经在multiHeaders出现,则说明是multiheader,新值直接加入multiHeaders.
如果name已经在header出现,则说明是multiheader,之前值移入multiHeaders并从headers中移除,新值直接加入multiHeaders.
否则加入headers.
void http::Header::addMultiHeader | ( | winux::String const & | name, |
winux::String const & | value | ||
) |
void http::Header::clear | ( | ) |
清空
|
inline |
在文件 http_misc.hpp 第 92 行定义.
void http::Header::delMultiHeader | ( | int | index | ) |
bool http::Header::enumHeader | ( | winux::String * | name, |
winux::String * | value | ||
) | const |
枚举所有头域一遍,多次调用即可,当完成枚举后返回false。再次调用即可重新枚举。
|
inline |
在文件 http_misc.hpp 第 95 行定义.
|
inline |
在文件 http_misc.hpp 第 105 行定义.
|
inline |
在文件 http_misc.hpp 第 82 行定义.
|
inline |
在文件 http_misc.hpp 第 83 行定义.
winux::StringArray http::Header::getHeaders | ( | winux::String const & | name | ) | const |
取得所有指定name的field值
|
inline |
方法. For a request: required.
在文件 http_misc.hpp 第 137 行定义.
winux::String http::Header::getMultiHeader | ( | winux::String const & | name, |
int | i, | ||
winux::String const & | defval = winux::String() |
||
) | const |
|
inline |
状态码. For a response: required.
在文件 http_misc.hpp 第 141 行定义.
winux::String http::Header::getStatusLine | ( | bool | isAddCrlf = false | ) | const |
取得状态行,isAddCrlf指示末尾是否添加‘回车换行’,默认不添加
|
inline |
状态文本. For a response: Not required
在文件 http_misc.hpp 第 143 行定义.
|
inline |
URL. For a request: required.
在文件 http_misc.hpp 第 139 行定义.
|
inline |
|
inline |
在文件 http_misc.hpp 第 91 行定义.
bool http::Header::hasMultiHeader | ( | winux::String const & | name | ) | const |
winux::StringWriter http::Header::operator() | ( | winux::String const & | name | ) |
设置headers,可以增加新头域
winux::StringWriter http::Header::operator() | ( | winux::String const & | name, |
int | i | ||
) |
修改multiheaders,无法增加新头域
i | 指定是第几个,base on 0 |
winux::String const& http::Header::operator[] | ( | winux::String const & | name | ) | const |
winux::String& http::Header::operator[] | ( | winux::String const & | name | ) |
Header& http::Header::parse | ( | winux::String const & | headerStr | ) |
从"HeaderField: XXXXX"字符串解析头部,可重复调用,不会清空先前解析的结果,要清空请调用clear()
|
inline |
在文件 http_misc.hpp 第 90 行定义.
|
inline |
方法. For a request: required.
在文件 http_misc.hpp 第 151 行定义.
void http::Header::setRequestLine | ( | winux::String const & | requestLine | ) |
设置请求行 格式: Method URL HttpVersion
eg. GET /index.do HTTP/1.1
void http::Header::setResponseLine | ( | winux::String const & | responseLine, |
bool | setStatus = true |
||
) |
设置响应行 格式: HttpVersion StatusCode StatusStr
eg. HTTP/1.1 200 OK
setStatus | 指示是否同时设置"Status:"头域,FCGI程序必须用Status修改响应状态码 |
|
inline |
状态码. For a response: required.
在文件 http_misc.hpp 第 155 行定义.
|
inline |
状态文本. For a response: Not required
在文件 http_misc.hpp 第 157 行定义.
|
inline |
URL. For a request: required.
在文件 http_misc.hpp 第 153 行定义.
|
inline |
winux::String http::Header::toString | ( | bool | isAddCrlfAtEnd = true | ) | const |
转为字符串,isAddCrlfAtEnd指示末尾是否添加\r\n