2019-04-24 04:50:25 +02:00
|
|
|
// Copyright (c) 2019 The Chromium Embedded Framework 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 CEF_LIBCEF_COMMON_NET_SERVICE_NET_SERVICE_UTIL_H_
|
|
|
|
#define CEF_LIBCEF_COMMON_NET_SERVICE_NET_SERVICE_UTIL_H_
|
|
|
|
|
|
|
|
#include <map>
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#include "include/internal/cef_types_wrappers.h"
|
|
|
|
|
2020-03-04 01:29:39 +01:00
|
|
|
#include "base/memory/scoped_refptr.h"
|
2020-04-24 23:48:16 +02:00
|
|
|
#include "net/cookies/cookie_constants.h"
|
2020-03-04 01:29:39 +01:00
|
|
|
|
2019-04-24 04:50:25 +02:00
|
|
|
namespace net {
|
|
|
|
class CanonicalCookie;
|
|
|
|
class HttpResponseHeaders;
|
|
|
|
struct RedirectInfo;
|
|
|
|
} // namespace net
|
|
|
|
|
|
|
|
namespace network {
|
|
|
|
struct ResourceRequest;
|
|
|
|
} // namespace network
|
|
|
|
|
|
|
|
class GURL;
|
|
|
|
|
|
|
|
namespace net_service {
|
|
|
|
|
|
|
|
// HTTP header names.
|
|
|
|
extern const char kHTTPLocationHeaderName[];
|
|
|
|
extern const char kHTTPSetCookieHeaderName[];
|
|
|
|
|
2019-05-11 00:14:48 +02:00
|
|
|
// HTTP header values.
|
|
|
|
extern const char kContentTypeApplicationFormURLEncoded[];
|
|
|
|
|
2019-04-24 04:50:25 +02:00
|
|
|
// Make an HTTP response status line.
|
|
|
|
// Set |for_replacement| to true if the result will be passed to
|
|
|
|
// HttpResponseHeaders::ReplaceStatusLine and false if the result will
|
|
|
|
// be passed to the HttpResponseHeaders constructor.
|
|
|
|
std::string MakeStatusLine(int status_code,
|
|
|
|
const std::string& status_text,
|
|
|
|
bool for_replacement);
|
|
|
|
|
|
|
|
// Make an HTTP Content-Type response header value.
|
|
|
|
std::string MakeContentTypeValue(const std::string& mime_type,
|
|
|
|
const std::string& charset);
|
|
|
|
|
|
|
|
// Make a new HttpResponseHeaders object.
|
2020-03-04 01:29:39 +01:00
|
|
|
scoped_refptr<net::HttpResponseHeaders> MakeResponseHeaders(
|
2019-04-24 04:50:25 +02:00
|
|
|
int status_code,
|
|
|
|
const std::string& status_text,
|
|
|
|
const std::string& mime_type,
|
|
|
|
const std::string& charset,
|
|
|
|
int64_t content_length,
|
|
|
|
const std::multimap<std::string, std::string>& extra_headers,
|
|
|
|
bool allow_existing_header_override);
|
|
|
|
|
|
|
|
// Make a RedirectInfo structure.
|
|
|
|
net::RedirectInfo MakeRedirectInfo(const network::ResourceRequest& request,
|
|
|
|
const net::HttpResponseHeaders* headers,
|
|
|
|
const GURL& new_location,
|
|
|
|
int status_code);
|
|
|
|
|
|
|
|
// Populate |cookie|. Returns true on success.
|
|
|
|
bool MakeCefCookie(const net::CanonicalCookie& cc, CefCookie& cookie);
|
|
|
|
bool MakeCefCookie(const GURL& url,
|
|
|
|
const std::string& cookie_line,
|
|
|
|
CefCookie& cookie);
|
|
|
|
|
2020-04-24 23:48:16 +02:00
|
|
|
net::CookieSameSite MakeCookieSameSite(cef_cookie_same_site_t value);
|
|
|
|
net::CookiePriority MakeCookiePriority(cef_cookie_priority_t value);
|
|
|
|
|
2019-04-24 04:50:25 +02:00
|
|
|
} // namespace net_service
|
|
|
|
|
|
|
|
#endif // CEF_LIBCEF_COMMON_NET_SERVICE_NET_SERVICE_UTIL_H_
|