blob: 51265420504d40fabf2194a0e9d16dc04efa55ec [file] [log] [blame]
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef FetchUtils_h
#define FetchUtils_h
#include "platform/PlatformExport.h"
#include "platform/wtf/Allocator.h"
#include "platform/wtf/Forward.h"
namespace blink {
class HTTPHeaderMap;
class PLATFORM_EXPORT FetchUtils {
STATIC_ONLY(FetchUtils);
public:
static bool IsSimpleMethod(const String& method);
static bool IsSimpleHeader(const AtomicString& name,
const AtomicString& value);
static bool IsSimpleContentType(const AtomicString& media_type);
static bool IsSimpleRequest(const String& method, const HTTPHeaderMap&);
static bool IsForbiddenMethod(const String& method);
static bool IsUsefulMethod(const String& method) {
return !IsForbiddenMethod(method);
}
static bool IsForbiddenHeaderName(const String& name);
static bool IsForbiddenResponseHeaderName(const String& name);
static bool IsSimpleOrForbiddenRequest(const String& method,
const HTTPHeaderMap&);
static AtomicString NormalizeMethod(const AtomicString& method);
static String NormalizeHeaderValue(const String& value);
// https://fetch.spec.whatwg.org/#ok-status aka a successful 2xx status
// code, https://tools.ietf.org/html/rfc7231#section-6.3 . We opt to use
// the Fetch term in naming the predicate.
static bool IsOkStatus(int status) { return status >= 200 && status < 300; }
};
} // namespace blink
#endif