Commit adb2032a authored by Zhu Jiashun's avatar Zhu Jiashun Committed by zhujiashun

Add http2.

TODO: 1. socket management 2. window mechanism
parent b232a463
......@@ -24,7 +24,9 @@ namespace brpc {
HttpHeader::HttpHeader()
: _status_code(HTTP_STATUS_OK)
, _method(HTTP_METHOD_GET)
, _version(1, 1) {
, _version(1, 1)
, _h2_stream_id(0)
, _h2_error(H2_NO_ERROR) {
// NOTE: don't forget to clear the field in Clear() as well.
}
......@@ -48,6 +50,8 @@ void HttpHeader::Swap(HttpHeader &rhs) {
_content_type.swap(rhs._content_type);
_unresolved_path.swap(rhs._unresolved_path);
std::swap(_version, rhs._version);
std::swap(_h2_stream_id, rhs._h2_stream_id);
std::swap(_h2_error, rhs._h2_error);
}
void HttpHeader::Clear() {
......@@ -58,6 +62,8 @@ void HttpHeader::Clear() {
_content_type.clear();
_unresolved_path.clear();
_version = std::make_pair(1, 1);
_h2_stream_id = 0;
_h2_error = H2_NO_ERROR;
}
const char* HttpHeader::reason_phrase() const {
......
......@@ -63,6 +63,12 @@ public:
// True if the message is from HTTP2.
bool is_http2() const { return major_version() == 2; }
// Id of the HTTP2 stream where the message is from.
// 0 when is_http2() is false.
int h2_stream_id() const { return _h2_stream_id; }
H2Error h2_error() const { return _h2_error; }
// Get/set "Content-Type". Notice that you can't get "Content-Type"
// via GetHeader().
// possible values: "text/plain", "application/json" ...
......@@ -154,6 +160,8 @@ friend void policy::ProcessHttpRequest(InputMessageBase *msg);
std::string _content_type;
std::string _unresolved_path;
std::pair<int, int> _version;
int _h2_stream_id;
H2Error _h2_error;
};
const HttpHeader& DefaultHttpHeader();
......
diff a/src/brpc/options.proto b/src/brpc/options.proto (rejected hunks)
@@ -53,6 +53,7 @@ enum ProtocolType {
// Reserve special protocol for cds-agent, which depends on FIFO right now
PROTOCOL_CDS_AGENT = 23; // Client side only
PROTOCOL_ESP = 24; // Client side only
+ PROTOCOL_HTTP2 = 25;
}
message ChunkInfo {
......@@ -53,8 +53,7 @@ class RtmpService;
class SocketSSLContext;
struct ServerOptions {
// Constructed with default options.
ServerOptions();
ServerOptions(); // Constructed with default options.
// connections without data transmission for so many seconds will be closed
// Default: -1 (disabled)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment