Skip to content
This repository was archived by the owner on Aug 19, 2019. It is now read-only.

Commit f46fc20

Browse files
committed
Make an exact copy of the single entry for the batch request. (#174)
1 parent e610a7a commit f46fc20

1 file changed

Lines changed: 4 additions & 12 deletions

File tree

src/reporter.cc

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -97,18 +97,10 @@ void SendMetadataRequest(std::vector<json::value>&& entries,
9797
throw (boost::system::system_error) {
9898

9999
if (entries.size() == 1) {
100-
// Add a copy of the single entry, except for the `views` field. This allows
101-
// us to sent a request to the batch endpoint when we have a single request.
102-
// We're making use of the fact that duplicate metadata is ignored.
103-
const json::Object* single_request = entries[0]->As<json::Object>();
104-
json::value duplicate_request = json::object({ // ResourceMetadata
105-
{"name", single_request->at("name")->Clone()},
106-
{"type", single_request->at("type")->Clone()},
107-
{"location", single_request->at("location")->Clone()},
108-
{"state", single_request->at("state")->Clone()},
109-
{"evenTime", single_request->at("evenTime")->Clone()},
110-
});
111-
entries.emplace_back(std::move(duplicate_request));
100+
// A single request cannot be sent to the batch endpoint. In order to work
101+
// around this, we add a copy of this request. We're making use of the fact
102+
// that sending two identical requests is idempotent.
103+
entries.emplace_back(entries[0]->Clone());
112104
}
113105
const std::string content_type =
114106
std::string("multipart/mixed; boundary=") + kMultipartBoundary;

0 commit comments

Comments
 (0)