Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1014)

Unified Diff: native_client_sdk/src/tests/nacl_io_test/fake_ppapi/fake_util.cc

Issue 2513423002: [NaCl SDK] Implement FakeURLRequestInfoInterface::AppendDataToBody (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « native_client_sdk/src/tests/nacl_io_test/fake_ppapi/fake_util.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: native_client_sdk/src/tests/nacl_io_test/fake_ppapi/fake_util.cc
diff --git a/native_client_sdk/src/tests/nacl_io_test/fake_ppapi/fake_util.cc b/native_client_sdk/src/tests/nacl_io_test/fake_ppapi/fake_util.cc
index 32b32511feff91d226bcc9ffc9b0f35a5975ed99..bc85ec453d92e828e1f4d21f91df3859b1db039e 100644
--- a/native_client_sdk/src/tests/nacl_io_test/fake_ppapi/fake_util.cc
+++ b/native_client_sdk/src/tests/nacl_io_test/fake_ppapi/fake_util.cc
@@ -29,6 +29,35 @@ int32_t RunCompletionCallback(PP_CompletionCallback* callback, int32_t result) {
return result;
}
+void SetHeader(const std::string& key,
+ const std::string& value,
+ std::string* out_headers) {
+ std::string old_value;
+ if (!GetHeaderValue(*out_headers, key, &old_value)) {
+ *out_headers += key + ": " + value + "\n";
+ return;
+ }
+
+ size_t offset = 0;
+ while (offset != std::string::npos) {
+ // Find the next colon; this separates the key from the value.
+ size_t colon = out_headers->find(':', offset);
+
+ // Find the newline; this separates the value from the next header.
+ size_t newline = out_headers->find('\n', offset);
+ if (strncasecmp(key.c_str(), &out_headers->data()[offset], key.size()) ==
+ 0) {
+ *out_headers = out_headers->substr(0, colon) + ": " + value +
+ out_headers->substr(newline);
+
+ return;
+ }
+
+ // Key doesn't match, skip to next header.
+ offset = newline + 1;
+ }
+}
+
bool GetHeaderValue(const std::string& headers,
const std::string& key,
std::string* out_value) {
« no previous file with comments | « native_client_sdk/src/tests/nacl_io_test/fake_ppapi/fake_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698