• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2019 The Chromium Embedded Framework Authors. All rights
2 // reserved. Use of this source code is governed by a BSD-style license that
3 // can be found in the LICENSE file.
4 
5 #ifndef CEF_LIBCEF_COMMON_NET_SERVICE_NET_SERVICE_UTIL_H_
6 #define CEF_LIBCEF_COMMON_NET_SERVICE_NET_SERVICE_UTIL_H_
7 
8 #include <map>
9 #include <string>
10 
11 #include "include/internal/cef_types_wrappers.h"
12 
13 #include "base/memory/scoped_refptr.h"
14 #include "net/cookies/cookie_constants.h"
15 
16 namespace net {
17 class CanonicalCookie;
18 class HttpResponseHeaders;
19 struct RedirectInfo;
20 }  // namespace net
21 
22 namespace network {
23 struct ResourceRequest;
24 }  // namespace network
25 
26 class GURL;
27 
28 namespace net_service {
29 
30 // HTTP header names.
31 extern const char kHTTPLocationHeaderName[];
32 extern const char kHTTPSetCookieHeaderName[];
33 
34 // HTTP header values.
35 extern const char kContentTypeApplicationFormURLEncoded[];
36 
37 // Make an HTTP response status line.
38 // Set |for_replacement| to true if the result will be passed to
39 // HttpResponseHeaders::ReplaceStatusLine and false if the result will
40 // be passed to the HttpResponseHeaders constructor.
41 std::string MakeStatusLine(int status_code,
42                            const std::string& status_text,
43                            bool for_replacement);
44 
45 // Make an HTTP Content-Type response header value.
46 std::string MakeContentTypeValue(const std::string& mime_type,
47                                  const std::string& charset);
48 
49 // Make a new HttpResponseHeaders object.
50 scoped_refptr<net::HttpResponseHeaders> MakeResponseHeaders(
51     int status_code,
52     const std::string& status_text,
53     const std::string& mime_type,
54     const std::string& charset,
55     int64_t content_length,
56     const std::multimap<std::string, std::string>& extra_headers,
57     bool allow_existing_header_override);
58 
59 // Make a RedirectInfo structure.
60 net::RedirectInfo MakeRedirectInfo(const network::ResourceRequest& request,
61                                    const net::HttpResponseHeaders* headers,
62                                    const GURL& new_location,
63                                    int status_code);
64 
65 // Populate |cookie|. Returns true on success.
66 bool MakeCefCookie(const net::CanonicalCookie& cc, CefCookie& cookie);
67 bool MakeCefCookie(const GURL& url,
68                    const std::string& cookie_line,
69                    CefCookie& cookie);
70 
71 net::CookieSameSite MakeCookieSameSite(cef_cookie_same_site_t value);
72 net::CookiePriority MakeCookiePriority(cef_cookie_priority_t value);
73 
74 }  // namespace net_service
75 
76 #endif  // CEF_LIBCEF_COMMON_NET_SERVICE_NET_SERVICE_UTIL_H_
77