Update engine properly sets Content-Type to text/xml.
Since the payload sent to Omaha is XML encoded, update engine should
properly set the HTTP Content-Type header to text/xml, instead of using
the libcurl default (application/x-www-form-urlencoded).
BUG=chromium-os:7613
TEST=Tested against devserver, ensuring that Content-Type is set
correctly
Change-Id: I9766e8dd67ffd387634a0ab4ef83c2990b16b537
Reviewed-on: https://gerrit.chromium.org/gerrit/16051
Reviewed-by: Andrew de los Reyes <adlr@chromium.org>
Tested-by: Gilad Arnold <garnold@chromium.org>
Commit-Ready: Gilad Arnold <garnold@chromium.org>
diff --git a/http_common.cc b/http_common.cc
index 647faba..bf4e69d 100644
--- a/http_common.cc
+++ b/http_common.cc
@@ -51,3 +51,21 @@
HttpResponseCode StringToHttpResponseCode(const char *s) {
return static_cast<HttpResponseCode>(strtoul(s, NULL, 10));
}
+
+
+const char *GetHttpContentTypeString(HttpContentType type) {
+ static const struct {
+ HttpContentType type;
+ const char* str;
+ } http_content_type_table[] = {
+ { kHttpContentTypeTextXml, "text/xml" },
+ };
+
+ bool is_found = false;
+ size_t i;
+ for (i = 0; i < ARRAYSIZE_UNSAFE(http_content_type_table); i++)
+ if ((is_found = (http_content_type_table[i].type == type)))
+ break;
+
+ return (is_found ? http_content_type_table[i].str : NULL);
+}