blob: a6b201a750d302f1a64c6d2d0bdafca077a64fd2 [file] [log] [blame]
// Copyright 2017 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.
#include "base/component_export.h"
#include "base/memory/ref_counted.h"
class GURL;
namespace net {
class HttpRawRequestHeaders;
class HttpRequestHeaders;
class HttpResponseHeaders;
class URLRequest;
} // namespace net
// This header contains utility functions and constants shared between network
// service and the old loading path in content/. Once Network Service is the
// only path this should move out of the public directory.
namespace network {
struct HttpRawRequestResponseInfo;
struct ResourceResponse;
// Enumeration for UMA histograms logged by LogConcerningRequestHeaders().
// Entries should not be renumbered and numeric values should never be reused.
// Please keep in sync with "NetworkServiceConcerningRequestHeaders" in
// src/tools/metrics/histograms/enums.xml.
enum class ConcerningHeaderId {
kConnection = 0,
kCookie = 1,
kCookie2 = 2,
kContentTransferEncoding = 3,
kDate = 4,
kExpect = 5,
kKeepAlive = 6,
kReferer = 7,
kTe = 8,
kTransferEncoding = 9,
kVia = 10,
kMaxValue = kVia,
// The name of the "Accept" header.
COMPONENT_EXPORT(NETWORK_SERVICE) extern const char kAcceptHeader[];
// Accept header used for frame requests.
extern const char kFrameAcceptHeader[];
// The default Accept header value to use if none were specified.
extern const char kDefaultAcceptHeader[];
// Helper utilities shared between network service and ResourceDispatcherHost
// code paths.
// Whether the response body should be sniffed in order to determine the MIME
// type of the response.
bool ShouldSniffContent(net::URLRequest* url_request,
ResourceResponse* response);
// Fill HttpRawRequestResponseInfo based on raw headers.
scoped_refptr<HttpRawRequestResponseInfo> BuildRawRequestResponseInfo(
const net::URLRequest& request,
const net::HttpRawRequestHeaders& raw_request_headers,
const net::HttpResponseHeaders* raw_response_headers);
// Returns the referrer based on the validity of the URL and command line flags.
std::string ComputeReferrer(const GURL& referrer);
void LogConcerningRequestHeaders(const net::HttpRequestHeaders& request_headers,
bool added_during_redirect);
} // namespace network