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

fix: ensure headers are set on first commit #1036

Merged
merged 2 commits into from
Nov 7, 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
4 changes: 0 additions & 4 deletions runtime/fastly/builtins/body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
#include <optional>
#include <string>

// TODO(GB) remove once https://github.com/bytecodealliance/StarlingMonkey/pull/75 lands
// clang-format off
#include "builtin.h"
// clang-format on
#include "../../../StarlingMonkey/builtins/web/fetch/fetch-errors.h"
#include "../../../StarlingMonkey/builtins/web/streams/native-stream-source.h"
#include "../../../StarlingMonkey/builtins/web/url.h"
Expand Down
12 changes: 11 additions & 1 deletion runtime/fastly/host-api/host_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -574,8 +574,18 @@ Result<HttpHeaders *> HttpHeaders::FromEntries(vector<tuple<HostString, HostStri
Result<Void>
write_headers(HttpHeaders *headers,
std::vector<std::tuple<host_api::HostString, host_api::HostString>> &list) {
std::vector<std::string_view> seen;
seen.reserve(list.size());
host_api::Result<host_api::Void> res;
for (const auto &[name, value] : list) {
auto res = headers->append(name, value);
if (std::find(seen.begin(), seen.end(), name) == seen.end()) {
// first time seeing a header -> use set in case of existing values on the handle
res = headers->set(name, value);
seen.push_back(name);
} else {
// seen before -> use append
res = headers->append(name, value);
}
if (res.is_err()) {
return res;
}
Expand Down
Loading