1 // Copyright (c) 2012 Marshall A. Greenblatt. All rights reserved. 2 // 3 // Redistribution and use in source and binary forms, with or without 4 // modification, are permitted provided that the following conditions are 5 // met: 6 // 7 // * Redistributions of source code must retain the above copyright 8 // notice, this list of conditions and the following disclaimer. 9 // * Redistributions in binary form must reproduce the above 10 // copyright notice, this list of conditions and the following disclaimer 11 // in the documentation and/or other materials provided with the 12 // distribution. 13 // * Neither the name of Google Inc. nor the name Chromium Embedded 14 // Framework nor the names of its contributors may be used to endorse 15 // or promote products derived from this software without specific prior 16 // written permission. 17 // 18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 // 30 // --------------------------------------------------------------------------- 31 // 32 // The contents of this file must follow a specific format in order to 33 // support the CEF translator tool. See the translator.README.txt file in the 34 // tools directory for more information. 35 // 36 37 #ifndef CEF_INCLUDE_CEF_RESPONSE_H_ 38 #define CEF_INCLUDE_CEF_RESPONSE_H_ 39 #pragma once 40 41 #include <map> 42 #include "include/cef_base.h" 43 44 /// 45 // Class used to represent a web response. The methods of this class may be 46 // called on any thread. 47 /// 48 /*--cef(source=library,no_debugct_check)--*/ 49 class CefResponse : public virtual CefBaseRefCounted { 50 public: 51 typedef std::multimap<CefString, CefString> HeaderMap; 52 53 /// 54 // Create a new CefResponse object. 55 /// 56 /*--cef()--*/ 57 static CefRefPtr<CefResponse> Create(); 58 59 /// 60 // Returns true if this object is read-only. 61 /// 62 /*--cef()--*/ 63 virtual bool IsReadOnly() = 0; 64 65 /// 66 // Get the response error code. Returns ERR_NONE if there was no error. 67 /// 68 /*--cef(default_retval=ERR_NONE)--*/ 69 virtual cef_errorcode_t GetError() = 0; 70 71 /// 72 // Set the response error code. This can be used by custom scheme handlers 73 // to return errors during initial request processing. 74 /// 75 /*--cef()--*/ 76 virtual void SetError(cef_errorcode_t error) = 0; 77 78 /// 79 // Get the response status code. 80 /// 81 /*--cef()--*/ 82 virtual int GetStatus() = 0; 83 84 /// 85 // Set the response status code. 86 /// 87 /*--cef()--*/ 88 virtual void SetStatus(int status) = 0; 89 90 /// 91 // Get the response status text. 92 /// 93 /*--cef()--*/ 94 virtual CefString GetStatusText() = 0; 95 96 /// 97 // Set the response status text. 98 /// 99 /*--cef(optional_param=statusText)--*/ 100 virtual void SetStatusText(const CefString& statusText) = 0; 101 102 /// 103 // Get the response mime type. 104 /// 105 /*--cef()--*/ 106 virtual CefString GetMimeType() = 0; 107 108 /// 109 // Set the response mime type. 110 /// 111 /*--cef(optional_param=mimeType)--*/ 112 virtual void SetMimeType(const CefString& mimeType) = 0; 113 114 /// 115 // Get the response charset. 116 /// 117 /*--cef()--*/ 118 virtual CefString GetCharset() = 0; 119 120 /// 121 // Set the response charset. 122 /// 123 /*--cef(optional_param=charset)--*/ 124 virtual void SetCharset(const CefString& charset) = 0; 125 126 /// 127 // Get the value for the specified response header field. 128 /// 129 /*--cef()--*/ 130 virtual CefString GetHeaderByName(const CefString& name) = 0; 131 132 /// 133 // Set the header |name| to |value|. If |overwrite| is true any existing 134 // values will be replaced with the new value. If |overwrite| is false any 135 // existing values will not be overwritten. 136 /// 137 /*--cef(optional_param=value)--*/ 138 virtual void SetHeaderByName(const CefString& name, 139 const CefString& value, 140 bool overwrite) = 0; 141 142 /// 143 // Get all response header fields. 144 /// 145 /*--cef()--*/ 146 virtual void GetHeaderMap(HeaderMap& headerMap) = 0; 147 148 /// 149 // Set all response header fields. 150 /// 151 /*--cef()--*/ 152 virtual void SetHeaderMap(const HeaderMap& headerMap) = 0; 153 154 /// 155 // Get the resolved URL after redirects or changed as a result of HSTS. 156 /// 157 /*--cef()--*/ 158 virtual CefString GetURL() = 0; 159 160 /// 161 // Set the resolved URL after redirects or changed as a result of HSTS. 162 /// 163 /*--cef(optional_param=url)--*/ 164 virtual void SetURL(const CefString& url) = 0; 165 }; 166 167 #endif // CEF_INCLUDE_CEF_RESPONSE_H_ 168