Skip to content

Commit

Permalink
fix: serialzing WasmSourceURL when httpHeaders is empty (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
G4Vi authored Dec 5, 2023
1 parent c69036d commit b6c8dbb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/manifest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,13 @@ Json::Value Wasm::json() {
} else if (this->source == WasmSourceURL) {
doc["url"] = this->ref;
doc["method"] = this->httpMethod;

Json::Value h;
for (auto k : this->httpHeaders) {
h[k.first] = this->httpHeaders[k.second];
if (!this->httpHeaders.empty()) {
Json::Value h;
for (auto k : this->httpHeaders) {
h[k.first] = this->httpHeaders[k.second];
}
doc["headers"] = h;
}
doc["headers"] = h;
} else if (this->source == WasmSourceBytes) {
throw Error("TODO: WasmSourceBytes");
}
Expand Down
7 changes: 7 additions & 0 deletions test/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ TEST(Plugin, Manifest) {
ASSERT_TRUE(buf.string().find("\"count\":4") != std::string::npos);
}

TEST(Plugin, ManifestWasmUrl) {
const auto manifest =
extism::Manifest::wasmURL("https://github.com/extism/plugins/releases/"
"latest/download/count_vowels.wasm");
ASSERT_NO_THROW(extism::Plugin plugin(manifest, true));
}

TEST(Plugin, BadManifest) {
Manifest manifest;
ASSERT_THROW(Plugin plugin(manifest), Error);
Expand Down

0 comments on commit b6c8dbb

Please sign in to comment.