Skip to content

Commit

Permalink
Merge pull request #156 from ilovenoah/153-add-append-cgi-response-he…
Browse files Browse the repository at this point in the history
…ader

add duplicate header in cgi response
  • Loading branch information
ilovenoah authored Mar 9, 2024
2 parents 468cb8a + 8e88c83 commit 1b9a250
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/response/Response.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -465,8 +465,14 @@ void Response::_setCGIResponseHeader(const bool shouldKeepAlive) {
if (utils::compCaseInsensitive(key, "Set-Cookie") == 0) {
this->_setCookies.push_back(value);
} else {
this->_headers.insert(
std::pair<std::string, std::string>(key, value));
std::map<std::string, std::string>::iterator iter =
this->_headers.find(key);
if (iter != this->_headers.end()) {
iter->second.append(", " + value);
} else {
this->_headers.insert(
std::pair<std::string, std::string>(key, value));
}
}
}
std::streampos endPos = ss.tellg();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
host, localhost
port, 8080


GET /cgi-bin/duplicate_cgi_response_header.py HTTP/1.1
Host: test
Connection: close
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
HTTP/1.1 200 Ok
Connection: close
Content-Type: text/html
Status: 200 OK
X_test: test1, test2, test3

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import os

# ステータスとコンテントタイプのヘッダーを出力
print("Status: 200 OK")
print("Content-Type: text/html")
print("X_test: test1")
print("X_test: test2")
print("X_test: test3")
print() # ヘッダーの終わりを示す空行

0 comments on commit 1b9a250

Please sign in to comment.