2014-11-19 00:25:21 +08:00
|
|
|
|
#pragma once
|
2017-06-02 14:47:24 +08:00
|
|
|
|
#include "../acl_cpp_define.hpp"
|
2014-11-19 00:25:21 +08:00
|
|
|
|
#include <list>
|
2017-06-02 14:47:24 +08:00
|
|
|
|
#include "../stdlib/dbuf_pool.hpp"
|
|
|
|
|
#include "../http/http_type.hpp"
|
2014-11-19 00:25:21 +08:00
|
|
|
|
|
|
|
|
|
struct HTTP_HDR_RES;
|
|
|
|
|
struct HTTP_HDR_ENTRY;
|
|
|
|
|
|
|
|
|
|
namespace acl {
|
|
|
|
|
|
|
|
|
|
class string;
|
|
|
|
|
class HttpCookie;
|
|
|
|
|
|
|
|
|
|
/**
|
2015-11-09 22:11:21 +08:00
|
|
|
|
* HTTP ͷ<EFBFBD>࣬<EFBFBD><EFBFBD><EFBFBD>Թ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧͷ
|
|
|
|
|
*/
|
2016-02-05 10:10:24 +08:00
|
|
|
|
class ACL_CPP_API http_header : public dbuf_obj
|
2014-11-19 00:25:21 +08:00
|
|
|
|
{
|
|
|
|
|
public:
|
2015-11-09 22:11:21 +08:00
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD>캯<EFBFBD><EFBFBD>
|
2016-02-05 10:10:24 +08:00
|
|
|
|
* @param dbuf {dbuf_guard*} <EFBFBD>ǿ<EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD>ڴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2015-11-09 22:11:21 +08:00
|
|
|
|
*/
|
2016-02-05 10:10:24 +08:00
|
|
|
|
http_header(dbuf_guard* dbuf = NULL);
|
2014-11-19 00:25:21 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* HTTP <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD><EFBFBD><EFBFBD>캯<EFBFBD><EFBFBD>
|
|
|
|
|
* @param url {const char*} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> URL<EFBFBD><EFBFBD>url <EFBFBD><EFBFBD>ʽʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>£<EFBFBD>
|
|
|
|
|
* http://www.test.com/
|
|
|
|
|
* /cgi-bin/test.cgi
|
|
|
|
|
* http://www.test.com/cgi-bin/test.cgi
|
|
|
|
|
* http://www.test.com/cgi-bin/test.cgi?name=value
|
|
|
|
|
* /cgi-bin/test.cgi?name=value
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> url <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶΣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD><EFBFBD>Զ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> url <EFBFBD><EFBFBD><EFBFBD>в<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶΣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD><EFBFBD>Զ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> add_param <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD>øú<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><EFBFBD>Կ<EFBFBD><EFBFBD>Ե<EFBFBD><EFBFBD><EFBFBD> add_param <EFBFBD>Ⱥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD>ֻ<EFBFBD>в<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD>в<EFBFBD><EFBFBD><EFBFBD>ֵʱ<EFBFBD><EFBFBD><EFBFBD>ò<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ᱻ<EFBFBD><EFBFBD><EFBFBD>ԣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD>õ<EFBFBD><EFBFBD><EFBFBD> add_param <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2016-02-05 10:10:24 +08:00
|
|
|
|
* @param dbuf {dbuf_guard*} <EFBFBD>ǿ<EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD>ڴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
*/
|
2016-02-05 10:10:24 +08:00
|
|
|
|
http_header(const char* url, dbuf_guard* dbuf = NULL);
|
2014-11-19 00:25:21 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* HTTP <EFBFBD><EFBFBD>Ӧͷ<EFBFBD><EFBFBD><EFBFBD>캯<EFBFBD><EFBFBD>
|
|
|
|
|
* @param status {int} ״̬<EFBFBD><EFBFBD><EFBFBD>磺1xx, 2xx, 3xx, 4xx, 5xx
|
2016-02-05 10:10:24 +08:00
|
|
|
|
* @param dbuf {dbuf_guard*} <EFBFBD>ǿ<EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD>ڴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
*/
|
2016-02-05 10:10:24 +08:00
|
|
|
|
http_header(int status, dbuf_guard* dbuf = NULL);
|
2015-11-09 22:11:21 +08:00
|
|
|
|
|
2014-11-19 00:25:21 +08:00
|
|
|
|
virtual ~http_header(void);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD> HTTP ͷ<EFBFBD><EFBFBD>Ϣͬʱ<EFBFBD><EFBFBD><EFBFBD>ϴε<EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>Դ<EFBFBD>ͷ<EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
void reset(void);
|
|
|
|
|
|
2016-09-20 19:55:38 +08:00
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
2014-11-19 00:25:21 +08:00
|
|
|
|
// HTTP <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> HTTP <20><>Ӧͨ<D3A6>õķ<C3B5><C4B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2016-09-20 19:55:38 +08:00
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
2014-11-19 00:25:21 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD> HTTP ͷ<EFBFBD>ǿͻ<EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧͷ
|
|
|
|
|
* @param onoff {bool} true <EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD>Ӧͷ
|
|
|
|
|
* @return {http_header&} <EFBFBD><EFBFBD><EFBFBD>ر<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ã<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
http_header& set_request_mode(bool onoff);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD><EFBFBD> HTTP ͷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD>
|
|
|
|
|
* @param name {const char*} <EFBFBD>ֶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǿ<EFBFBD>ָ<EFBFBD><EFBFBD>
|
|
|
|
|
* @param value {const char*} <EFBFBD>ֶ<EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD>ǿ<EFBFBD>ָ<EFBFBD><EFBFBD>
|
2017-12-28 17:53:34 +08:00
|
|
|
|
* @param replace {bool} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ظ<EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>Ƿ<EFBFBD><EFBFBD>Զ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ǿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
* @return {http_header&} <EFBFBD><EFBFBD><EFBFBD>ر<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ã<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
2017-12-28 17:53:34 +08:00
|
|
|
|
http_header& add_entry(const char* name, const char* value,
|
|
|
|
|
bool replace = true);
|
2014-11-19 00:25:21 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD> HTTP ͷ<EFBFBD>е<EFBFBD> Content-Length <EFBFBD>ֶ<EFBFBD>
|
|
|
|
|
* @param n {int64} <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
|
|
|
|
|
* @return {http_header&} <EFBFBD><EFBFBD><EFBFBD>ر<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ã<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
2015-06-29 17:33:11 +08:00
|
|
|
|
#if defined(_WIN32) || defined(_WIN64)
|
2014-11-19 00:25:21 +08:00
|
|
|
|
http_header& set_content_length(__int64 n);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><EFBFBD> set_content_length <EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD> HTTP ͷ<EFBFBD>е<EFBFBD> Content-Length ֵ
|
|
|
|
|
* @return {int64}
|
|
|
|
|
*/
|
|
|
|
|
__int64 get_content_length() const
|
|
|
|
|
{
|
|
|
|
|
return content_length_;
|
|
|
|
|
}
|
|
|
|
|
#else
|
|
|
|
|
http_header& set_content_length(long long int n);
|
|
|
|
|
long long int get_content_length() const
|
|
|
|
|
{
|
|
|
|
|
return content_length_;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2015-07-05 01:29:35 +08:00
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD> HTTP <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧͷ<EFBFBD><EFBFBD><EFBFBD>е<EFBFBD> Range <EFBFBD>ֶΣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڷֶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD>
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֧<EFBFBD>ֶϵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> WEB <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param from {http_off_t} <EFBFBD><EFBFBD>ʼƫ<EFBFBD><EFBFBD>λ<EFBFBD>ã<EFBFBD><EFBFBD>±<EFBFBD><EFBFBD><EFBFBD> 0 <EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* ֵ<EFBFBD><EFBFBD> >= 0 ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч
|
|
|
|
|
* @param to {http_off_t} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƫ<EFBFBD><EFBFBD>λ<EFBFBD>ã<EFBFBD><EFBFBD>±<EFBFBD><EFBFBD><EFBFBD> 0 <EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD>
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD>е<EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> < 0 ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼλ<EFBFBD>ÿ<EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ճ<EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><EFBFBD>
|
|
|
|
|
* @return {http_header&} <EFBFBD><EFBFBD><EFBFBD>ر<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ã<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
#if defined(_WIN32) || defined(_WIN64)
|
|
|
|
|
http_header& set_range(__int64 from, __int64 to);
|
|
|
|
|
#else
|
|
|
|
|
http_header& set_range(long long from, long long to);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧͷ<EFBFBD>ڷֶδ<EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD>ô˺<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܳ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param total {http_off_t} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧͷ<EFBFBD><EFBFBD><EFBFBD>ò<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܳ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @return {http_header&}
|
|
|
|
|
*/
|
|
|
|
|
#if defined(_WIN32) || defined(_WIN64)
|
|
|
|
|
http_header& set_range_total(__int64 total);
|
|
|
|
|
#else
|
|
|
|
|
http_header& set_range_total(long long total);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> set_range <EFBFBD><EFBFBD><EFBFBD>õķֶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><EFBFBD>ֵ
|
|
|
|
|
* @param from {http_off_t*} <EFBFBD>ǿ<EFBFBD>ʱ<EFBFBD>洢<EFBFBD><EFBFBD>ʼλ<EFBFBD><EFBFBD>ƫ<EFBFBD><EFBFBD>
|
|
|
|
|
* @param to {http_off_t*} <EFBFBD>ǿ<EFBFBD>ʱ<EFBFBD>洢<EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><EFBFBD>ƫ<EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
#if defined(_WIN32) || defined(_WIN64)
|
|
|
|
|
void get_range(__int64* from, __int64* to);
|
|
|
|
|
#else
|
|
|
|
|
void get_range(long long int* from, long long int* to);
|
|
|
|
|
#endif
|
|
|
|
|
|
2014-11-19 00:25:21 +08:00
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD> HTTP ͷ<EFBFBD>е<EFBFBD> Content-Type <EFBFBD>ֶ<EFBFBD>
|
|
|
|
|
* @param value {const char*} <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
|
|
|
|
|
* @return {http_header&} <EFBFBD><EFBFBD><EFBFBD>ر<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ã<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
http_header& set_content_type(const char* value);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD> HTTP ͷ<EFBFBD>е<EFBFBD> Connection <EFBFBD>ֶΣ<EFBFBD><EFBFBD>Ƿֳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀǰ<EFBFBD><EFBFBD>δ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>֧<EFBFBD>ֳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӣ<EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˸ñ<EFBFBD>־λ<EFBFBD><EFBFBD>
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD><EFBFBD>ݺ<EFBFBD>Ҳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ر<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param on {bool} <EFBFBD>Ƿֳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @return {http_header&} <EFBFBD><EFBFBD><EFBFBD>ر<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ã<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
http_header& set_keep_alive(bool on);
|
|
|
|
|
|
2015-07-13 16:28:09 +08:00
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD>鵱ǰͷ<EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˱<EFBFBD><EFBFBD>ֳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
bool get_keep_alive() const
|
|
|
|
|
{
|
|
|
|
|
return keep_alive_;
|
|
|
|
|
}
|
|
|
|
|
|
2016-09-20 19:55:38 +08:00
|
|
|
|
http_header& set_upgrade(const char* value = "websocket");
|
|
|
|
|
const char* get_upgrade(void) const
|
|
|
|
|
{
|
|
|
|
|
return upgrade_;
|
|
|
|
|
}
|
|
|
|
|
|
2014-11-19 00:25:21 +08:00
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD><EFBFBD> HTTP ͷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> cookie
|
|
|
|
|
* @param name {const char*} cookie <EFBFBD><EFBFBD>
|
|
|
|
|
* @param value {const char*} cookie ֵ
|
|
|
|
|
* @param domain {const char*} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param path {const char*} <EFBFBD>洢·<EFBFBD><EFBFBD>
|
|
|
|
|
* @param expires {time_t} <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>䣬<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵΪ 0 ʱ<EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD>
|
|
|
|
|
* > 0 ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> expires <EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>䣬<EFBFBD><EFBFBD>λΪ<EFBFBD><EFBFBD>
|
|
|
|
|
* @return {http_header&} <EFBFBD><EFBFBD><EFBFBD>ر<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ã<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
http_header& add_cookie(const char* name, const char* value,
|
|
|
|
|
const char* domain = NULL, const char* path = NULL,
|
|
|
|
|
time_t expires = 0);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD><EFBFBD> HTTP ͷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> cookie
|
2015-11-09 22:11:21 +08:00
|
|
|
|
* @param cookie {const http_cookie*} cookie <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
* @return {http_header&} <EFBFBD><EFBFBD><EFBFBD>ر<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ã<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
2015-11-09 22:11:21 +08:00
|
|
|
|
http_header& add_cookie(const HttpCookie* cookie);
|
2014-11-19 00:25:21 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><EFBFBD>Ϊ rfc1123 <EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
static void date_format(char* out, size_t size, time_t t);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD>ж<EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD> HTTP <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ
|
|
|
|
|
* @return {bool} <EFBFBD><EFBFBD><EFBFBD><EFBFBD> false <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> HTTP <EFBFBD><EFBFBD>Ӧͷ
|
|
|
|
|
*/
|
|
|
|
|
bool is_request(void) const;
|
|
|
|
|
|
2016-09-20 19:55:38 +08:00
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
|
// HTTP <20><><EFBFBD><EFBFBD><F3B7BDB7><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
2014-11-19 00:25:21 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD> HTTP <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param buf {string&} <EFBFBD>洢<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @return {bool} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD>з<EFBFBD><EFBFBD>ɹ<EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
bool build_request(string& buf) const;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> URL<EFBFBD><EFBFBD>url <EFBFBD><EFBFBD>ʽʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>£<EFBFBD>
|
|
|
|
|
* 1<EFBFBD><EFBFBD>http://www.test.com/
|
|
|
|
|
* 2<EFBFBD><EFBFBD>/cgi-bin/test.cgi
|
|
|
|
|
* 3<EFBFBD><EFBFBD>http://www.test.com/cgi-bin/test.cgi
|
|
|
|
|
* 3<EFBFBD><EFBFBD>http://www.test.com/cgi-bin/test.cgi?name=value
|
|
|
|
|
* 4<EFBFBD><EFBFBD>/cgi-bin/test.cgi?name=value
|
|
|
|
|
* 5<EFBFBD><EFBFBD>http://www.test.com
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> url <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶΣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD><EFBFBD>Զ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> url <EFBFBD><EFBFBD><EFBFBD>в<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶΣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD><EFBFBD>Զ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> add_param <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD>øú<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><EFBFBD>Կ<EFBFBD><EFBFBD>Ե<EFBFBD><EFBFBD><EFBFBD> add_param <EFBFBD>Ⱥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD>ֻ<EFBFBD>в<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD>в<EFBFBD><EFBFBD><EFBFBD>ֵʱ<EFBFBD><EFBFBD><EFBFBD>ò<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ᱻ<EFBFBD><EFBFBD><EFBFBD>ԣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD>õ<EFBFBD><EFBFBD><EFBFBD> add_param <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param url {const char*} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> url<EFBFBD><EFBFBD><EFBFBD>ǿ<EFBFBD>ָ<EFBFBD><EFBFBD>
|
2016-04-30 11:49:41 +08:00
|
|
|
|
* @param encoding {bool} <EFBFBD>Ƿ<EFBFBD><EFBFBD>Դ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> url <EFBFBD>еIJ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> url <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
* @return {http_header&} <EFBFBD><EFBFBD><EFBFBD>ر<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ã<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
2016-04-30 11:49:41 +08:00
|
|
|
|
http_header& set_url(const char* url, bool encoding = true);
|
2014-11-19 00:25:21 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD> HTTP <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD><EFBFBD> HOST <EFBFBD>ֶ<EFBFBD>
|
|
|
|
|
* @param value {const char*} <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD><EFBFBD> HOST <EFBFBD>ֶ<EFBFBD>ֵ
|
|
|
|
|
* @return {http_header&} <EFBFBD><EFBFBD><EFBFBD>ر<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ã<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
http_header& set_host(const char* value);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD> HTTP <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD>е<EFBFBD> HOST <EFBFBD>ֶ<EFBFBD>
|
|
|
|
|
* @return {const char*} <EFBFBD><EFBFBD><EFBFBD>ؿ<EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾû<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> HOST <EFBFBD>ֶ<EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
const char* get_host() const
|
|
|
|
|
{
|
|
|
|
|
return host_[0] == 0 ? NULL : host_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD> HTTP Э<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ô˺<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĭ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> GET <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param method {http_method_t} HTTP <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @return {http_header&} <EFBFBD><EFBFBD><EFBFBD>ر<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ã<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
http_header& set_method(http_method_t method);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD> HTTP Э<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><EFBFBD><EFBFBD>չ HTTP <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* ͨ<EFBFBD><EFBFBD><EFBFBD>ú<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӱ<EFBFBD><EFBFBD> HTTP <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param method {const char*} <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @return {http_header&} <EFBFBD><EFBFBD><EFBFBD>ر<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ã<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
http_header& set_method(const char* method);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD>õ<EFBFBD>ǰ<EFBFBD>ʼ<EFBFBD>ͷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2015-12-19 12:08:14 +08:00
|
|
|
|
* @param buf {string*} <EFBFBD>洢<EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
* @return {http_method_t}
|
|
|
|
|
*/
|
2015-12-19 12:08:14 +08:00
|
|
|
|
http_method_t get_method(string* buf = NULL) const;
|
2014-11-19 00:25:21 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD> HTTP <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD> HTTP ͷ<EFBFBD>ֶ<EFBFBD>Ϊ<EFBFBD><EFBFBD>
|
|
|
|
|
* Accept-Encoding: gzip, deflate<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀǰ<EFBFBD><EFBFBD>֧<EFBFBD><EFBFBD> gzip <EFBFBD><EFBFBD>ʽ
|
|
|
|
|
* @param on {bool} <EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ true <EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> HTTP ѹ<EFBFBD><EFBFBD>ͷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @return {http_header&} <EFBFBD><EFBFBD><EFBFBD>ر<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ã<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
http_header& accept_gzip(bool on);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> URL <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԣ<EFBFBD><EFBFBD><EFBFBD>ֻ<EFBFBD>в<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD>в<EFBFBD><EFBFBD><EFBFBD>ֵʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* 1<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǿմ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵΪ<EFBFBD><EFBFBD>ָ<EFBFBD>룬<EFBFBD><EFBFBD> URL <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֻ<EFBFBD>У<EFBFBD>{name}
|
|
|
|
|
* 2<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǿմ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵΪ<EFBFBD>մ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> URL<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>{name}=
|
|
|
|
|
* @param name {const char*} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD>
|
|
|
|
|
* @param value {const char*} <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @return {http_header&} <EFBFBD><EFBFBD><EFBFBD>ر<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ã<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
http_header& add_param(const char* name, const char* value);
|
|
|
|
|
http_header& add_int(const char* name, short value);
|
|
|
|
|
http_header& add_int(const char* name, int value);
|
|
|
|
|
http_header& add_int(const char* name, long value);
|
|
|
|
|
http_header& add_int(const char* name, unsigned short value);
|
|
|
|
|
http_header& add_int(const char* name, unsigned int value);
|
|
|
|
|
http_header& add_int(const char* name, unsigned long value);
|
|
|
|
|
http_header& add_format(const char* name, const char* fmt, ...)
|
|
|
|
|
ACL_CPP_PRINTF(3, 4);
|
2015-06-29 17:33:11 +08:00
|
|
|
|
#if defined(_WIN32) || defined(_WIN64)
|
2014-11-19 00:25:21 +08:00
|
|
|
|
http_header& add_int(const char* name, __int64 vlaue);
|
|
|
|
|
http_header& add_int(const char* name, unsigned __int64 vlaue);
|
|
|
|
|
#else
|
|
|
|
|
http_header& add_int(const char* name, long long int value);
|
|
|
|
|
http_header& add_int(const char* name, unsigned long long int value);
|
|
|
|
|
#endif
|
|
|
|
|
|
2016-09-20 19:55:38 +08:00
|
|
|
|
http_header& set_ws_origin(const char* url);
|
|
|
|
|
http_header& set_ws_key(const char* key);
|
|
|
|
|
http_header& set_ws_protocol(const char* proto);
|
|
|
|
|
http_header& set_ws_version(int ver);
|
|
|
|
|
|
|
|
|
|
const char* get_ws_origin(void) const
|
|
|
|
|
{
|
|
|
|
|
return ws_origin_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const char* get_ws_key(void) const
|
|
|
|
|
{
|
|
|
|
|
return ws_sec_key_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const char* get_ws_protocol(void) const
|
|
|
|
|
{
|
|
|
|
|
return ws_sec_proto_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int get_ws_version(void) const
|
|
|
|
|
{
|
|
|
|
|
return ws_sec_ver_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
http_header& set_ws_accept(const char* key);
|
|
|
|
|
const char* get_ws_accept(void) const
|
|
|
|
|
{
|
|
|
|
|
return ws_sec_accept_;
|
|
|
|
|
}
|
|
|
|
|
|
2014-11-19 00:25:21 +08:00
|
|
|
|
/**
|
|
|
|
|
* url <EFBFBD>ض<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param url {const char*} <EFBFBD>ض<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> URL<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽΪ<EFBFBD><EFBFBD>
|
|
|
|
|
* http://xxx.xxx.xxx/xxx <20><> /xxx
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD>ߣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD> HOST <EFBFBD>ֶΣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ǻ<EFBFBD><EFBFBD>ߣ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>֮ǰ<EFBFBD><EFBFBD> HOST
|
|
|
|
|
*/
|
|
|
|
|
bool redirect(const char* url);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ض<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ == 0 <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ض<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ض<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ض<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɸ<EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param n {int} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ض<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @return {http_header&} <EFBFBD><EFBFBD><EFBFBD>ر<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ã<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
http_header& set_redirect(unsigned int n = 5);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD><EFBFBD>ȡͨ<EFBFBD><EFBFBD> set_redirect <EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ض<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @return {unsigned int}
|
|
|
|
|
*/
|
|
|
|
|
unsigned int get_redirect(void) const;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>ض<EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ô˺<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һЩ<EFBFBD><EFBFBD><EFBFBD>ù<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
virtual void redicrect_reset(void) {}
|
|
|
|
|
|
2016-09-20 19:55:38 +08:00
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
|
// HTTP <20><>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
2014-11-19 00:25:21 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD> HTTP <EFBFBD><EFBFBD>Ӧͷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param buf {string&} <EFBFBD>洢<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @return {bool} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧͷ<EFBFBD>з<EFBFBD><EFBFBD>ɹ<EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
bool build_response(string& buf) const;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD> HTTP <EFBFBD><EFBFBD>Ӧͷ<EFBFBD>е<EFBFBD><EFBFBD><EFBFBD>Ӧ״̬<EFBFBD><EFBFBD>
|
|
|
|
|
* @param status {int} ״̬<EFBFBD><EFBFBD><EFBFBD>磺1xx, 2xx, 3xx, 4xx, 5xx
|
|
|
|
|
* @return {http_header&} <EFBFBD><EFBFBD><EFBFBD>ر<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ã<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
http_header& set_status(int status);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD> HTTP <EFBFBD><EFBFBD>Ӧͷ<EFBFBD>е<EFBFBD> chunked <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־
|
|
|
|
|
* @param on {bool}
|
|
|
|
|
* @return {http_header&}
|
|
|
|
|
*/
|
|
|
|
|
http_header& set_chunked(bool on);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD>жϵ<EFBFBD>ǰ HTTP <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> chunked <EFBFBD><EFBFBD><EFBFBD>䷽ʽ
|
|
|
|
|
* @return {bool}
|
|
|
|
|
*/
|
|
|
|
|
bool chunked_transfer() const
|
|
|
|
|
{
|
|
|
|
|
return chunked_transfer_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> CGI <EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧͷ
|
|
|
|
|
* @param on {bool} <EFBFBD>Ƿ<EFBFBD> CGI <EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD>Ӧͷ
|
|
|
|
|
* @return {http_header&} <EFBFBD><EFBFBD><EFBFBD>ر<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ã<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
http_header& set_cgi_mode(bool on);
|
|
|
|
|
|
2015-08-18 20:58:56 +08:00
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> CGI ģʽ
|
|
|
|
|
* @return {bool}
|
|
|
|
|
*/
|
|
|
|
|
bool is_cgi_mode() const
|
|
|
|
|
{
|
|
|
|
|
return cgi_mode_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD>ô<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> gzip <EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѹ<EFBFBD><EFBFBD>
|
|
|
|
|
* @param on {bool}
|
|
|
|
|
* @return {http_header&}
|
|
|
|
|
*/
|
|
|
|
|
http_header& set_transfer_gzip(bool on);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˲<EFBFBD><EFBFBD><EFBFBD> gzip ѹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ
|
|
|
|
|
* @return {bool}
|
|
|
|
|
*/
|
|
|
|
|
bool is_transfer_gzip() const
|
|
|
|
|
{
|
|
|
|
|
return transfer_gzip_;
|
|
|
|
|
}
|
|
|
|
|
|
2014-11-19 00:25:21 +08:00
|
|
|
|
private:
|
2016-02-05 10:10:24 +08:00
|
|
|
|
dbuf_guard* dbuf_internal_;
|
|
|
|
|
dbuf_guard* dbuf_;
|
2014-11-19 00:25:21 +08:00
|
|
|
|
//char* domain_; // HTTP <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2015-08-18 20:58:56 +08:00
|
|
|
|
//unsigned short port_; // HTTP <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
char* url_; // HTTP <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> URL
|
|
|
|
|
std::list<HTTP_PARAM*> params_; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
std::list<HttpCookie*> cookies_; // cookies <20><><EFBFBD><EFBFBD>
|
|
|
|
|
std::list<HTTP_HDR_ENTRY*> entries_; // HTTP <20><><EFBFBD><EFBFBD>ͷ<EFBFBD>и<EFBFBD><D0B8>ֶμ<D6B6><CEBC><EFBFBD>
|
|
|
|
|
http_method_t method_; // HTTP <20><><EFBFBD><EFBFBD><EFBFBD>ķ<EFBFBD><C4B7><EFBFBD>
|
|
|
|
|
char method_s_[64]; // HTTP <20><><EFBFBD><EFBFBD><F3B7BDB7><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD>ʾ
|
|
|
|
|
char host_[256]; // HTTP <20><><EFBFBD><EFBFBD>ͷ<EFBFBD>е<EFBFBD> HOST <20>ֶ<EFBFBD>
|
|
|
|
|
bool keep_alive_; // <20>Ƿֳ<F1B1A3B3><D6B3><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
unsigned int nredirect_; // <20><><EFBFBD><EFBFBD><EFBFBD>ض<EFBFBD><D8B6><EFBFBD><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
bool accept_compress_; // <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
int status_; // <20><>Ӧͷ<D3A6><CDB7>״̬<D7B4><CCAC>
|
|
|
|
|
bool is_request_; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD><CDB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧͷ
|
|
|
|
|
bool cgi_mode_; // <20>Ƿ<EFBFBD> CGI <20><>Ӧͷ
|
2015-06-29 17:33:11 +08:00
|
|
|
|
#if defined(_WIN32) || defined(_WIN64)
|
2014-11-19 00:25:21 +08:00
|
|
|
|
__int64 range_from_; // <20><><EFBFBD><EFBFBD>ͷ<EFBFBD>У<EFBFBD>range <20><>ʼλ<CABC><CEBB>
|
|
|
|
|
__int64 range_to_; // <20><><EFBFBD><EFBFBD>ͷ<EFBFBD>У<EFBFBD>range <20><><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
|
2015-07-05 01:29:35 +08:00
|
|
|
|
__int64 range_total_; // range <20><><EFBFBD><EFBFBD>ģʽ<C4A3>¼<EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD>ܳ<EFBFBD><DCB3><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
__int64 content_length_; // HTTP <20><><EFBFBD><EFBFBD><EFBFBD>峤<EFBFBD><E5B3A4>
|
|
|
|
|
#else
|
|
|
|
|
long long int range_from_; // <20><><EFBFBD><EFBFBD>ͷ<EFBFBD>У<EFBFBD>range <20><>ʼλ<CABC><CEBB>
|
|
|
|
|
long long int range_to_; // <20><><EFBFBD><EFBFBD>ͷ<EFBFBD>У<EFBFBD>range <20><><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
|
2015-07-05 01:29:35 +08:00
|
|
|
|
long long int range_total_; // range <20><><EFBFBD><EFBFBD>ģʽ<C4A3>¼<EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD>ܳ<EFBFBD><DCB3><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
long long int content_length_; // HTTP <20><><EFBFBD><EFBFBD><EFBFBD>峤<EFBFBD><E5B3A4>
|
|
|
|
|
#endif
|
|
|
|
|
bool chunked_transfer_; // <20>Ƿ<EFBFBD>Ϊ chunked <20><><EFBFBD><EFBFBD>ģʽ
|
2015-08-18 20:58:56 +08:00
|
|
|
|
bool transfer_gzip_; // <20><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD> gzip ѹ<><D1B9>
|
2016-09-20 19:55:38 +08:00
|
|
|
|
|
|
|
|
|
char* upgrade_;
|
|
|
|
|
// just for websocket
|
|
|
|
|
char* ws_origin_;
|
|
|
|
|
char* ws_sec_key_;
|
|
|
|
|
char* ws_sec_proto_;
|
|
|
|
|
int ws_sec_ver_;
|
|
|
|
|
char* ws_sec_accept_;
|
|
|
|
|
|
2014-11-19 00:25:21 +08:00
|
|
|
|
void init(void); // <20><>ʼ<EFBFBD><CABC>
|
|
|
|
|
void clear(void);
|
|
|
|
|
void build_common(string& buf) const; // <20><><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8>ͷ
|
2016-09-20 19:55:38 +08:00
|
|
|
|
|
|
|
|
|
void append_accept_key(const char* sec_key, string& out) const;
|
2014-11-19 00:25:21 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace acl end
|