wwbmmm commented on code in PR #2577:
URL: https://github.com/apache/brpc/pull/2577#discussion_r1545921201


##########
src/brpc/http_header.h:
##########
@@ -80,24 +85,39 @@ class HttpHeader {
     // Return pointer to the value, NULL on not found.
     // NOTE: If the key is "Content-Type", `GetHeader("Content-Type")'
     // (case-insensitive) is equal to `content_type()'.
-    const std::string* GetHeader(const char* key) const
-    { return _headers.seek(key); }
-    const std::string* GetHeader(const std::string& key) const
-    { return _headers.seek(key); }
+    const std::string* GetHeader(const char* key) const;
+    const std::string* GetHeader(const std::string& key) const;
+
+    std::vector<const std::string*> GetAllSetCookieHeader() const;

Review Comment:
   这个有什么用



##########
src/brpc/http_header.cpp:
##########
@@ -69,6 +54,70 @@ void HttpHeader::Clear() {
     _version = std::make_pair(1, 1);
 }
 
+const std::string* HttpHeader::GetHeader(const char* key) const {
+    HeaderIterator iter;
+    if (IsSetCookie(key)) {
+        iter = _first_set_cookie_iter;
+    } else {
+        iter = _headers.find(key);
+    }
+    return iter != _headers.end() ? &iter->second : NULL;
+}
+
+const std::string* HttpHeader::GetHeader(const std::string& key) const {
+    return GetHeader(key.c_str());
+}
+
+std::vector<const std::string*>
+HttpHeader::GetAllSetCookieHeader() const {
+    return GetMultiLineHeaders(SET_COOKIE);
+}
+
+std::vector<const std::string*>
+HttpHeader::GetMultiLineHeaders(const std::string& key) const {
+    std::vector<const std::string*> headers;
+    for (const auto& iter : _headers) {

Review Comment:
   遍历的效率会不会比较低



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org

Reply via email to