Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / core / fetch / FetchUtils.cpp
index 86ad9bb..8f9c453 100644 (file)
@@ -107,11 +107,10 @@ bool FetchUtils::isSimpleRequest(const String& method, const HTTPHeaderMap& head
     if (!isSimpleMethod(method))
         return false;
 
-    HTTPHeaderMap::const_iterator end = headerMap.end();
-    for (HTTPHeaderMap::const_iterator it = headerMap.begin(); it != end; ++it) {
+    for (const auto& header : headerMap) {
         // Preflight is required for MIME types that can not be sent via form
         // submission.
-        if (!isSimpleHeader(it->key, it->value))
+        if (!isSimpleHeader(header.key, header.value))
             return false;
     }
 
@@ -157,13 +156,37 @@ bool FetchUtils::isSimpleOrForbiddenRequest(const String& method, const HTTPHead
     if (!isSimpleMethod(method))
         return false;
 
-    HTTPHeaderMap::const_iterator end = headerMap.end();
-    for (HTTPHeaderMap::const_iterator it = headerMap.begin(); it != end; ++it) {
-        if (!isSimpleHeader(it->key, it->value) && !isForbiddenHeaderName(it->key))
+    for (const auto& header : headerMap) {
+        if (!isSimpleHeader(header.key, header.value) && !isForbiddenHeaderName(header.key))
             return false;
     }
 
     return true;
 }
 
+AtomicString FetchUtils::normalizeMethod(const AtomicString& method)
+{
+    // https://fetch.spec.whatwg.org/#concept-method-normalize
+
+    // We place GET and POST first because they are more commonly used than
+    // others.
+    const char* const methods[] = {
+        "GET",
+        "POST",
+        "DELETE",
+        "HEAD",
+        "OPTIONS",
+        "PUT",
+    };
+
+    for (const auto& known : methods) {
+        if (equalIgnoringCase(method, known)) {
+            // Don't bother allocating a new string if it's already all
+            // uppercase.
+            return method == known ? method : known;
+        }
+    }
+    return method;
+}
+
 } // namespace blink