Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add duplicate header in cgi response #156

Merged
merged 1 commit into from
Mar 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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() # ヘッダーの終わりを示す空行
Loading