namespace Cef3 { using System; using System.Collections.Generic; using System.Collections.Specialized; using System.Diagnostics; using System.Runtime.InteropServices; using Cef3.Interop; /// /// Class used to represent a web response. The methods of this class may be /// called on any thread. /// public sealed unsafe partial class CefResponse { /// /// Create a new CefResponse object. /// public static CefResponse Create() { return CefResponse.FromNative( cef_response_t.create() ); } /// /// Returns true if this object is read-only. /// public bool IsReadOnly { get { return cef_response_t.is_read_only(_self) != 0; } } /// /// Gets or sets the response status code. /// public int Status { get { return cef_response_t.get_status(_self); } set { cef_response_t.set_status(_self, value); } } /// /// Get the response status text. /// public string StatusText { get { var n_result = cef_response_t.get_status_text(_self); return cef_string_userfree.ToString(n_result); } set { fixed (char* value_str = value) { var n_value = new cef_string_t(value_str, value != null ? value.Length : 0); cef_response_t.set_status_text(_self, &n_value); } } } /// /// Gets or sets the response mime type. /// public string MimeType { get { var n_result = cef_response_t.get_mime_type(_self); return cef_string_userfree.ToString(n_result); } set { fixed (char* value_str = value) { var n_value = new cef_string_t(value_str, value != null ? value.Length : 0); cef_response_t.set_mime_type(_self, &n_value); } } } /// /// Get the value for the specified response header field. /// public string GetHeader(string name) { if (name == null) throw new ArgumentNullException("name"); fixed (char* name_str = name) { var n_name = new cef_string_t(name_str, name.Length); var n_result = cef_response_t.get_header(_self, &n_name); return cef_string_userfree.ToString(n_result); } } /// /// Get all response header fields. /// public NameValueCollection GetHeaderMap() { var headerMap = libcef.string_multimap_alloc(); cef_response_t.get_header_map(_self, headerMap); var result = cef_string_multimap.ToNameValueCollection(headerMap); libcef.string_multimap_free(headerMap); return result; } /// /// Set all response header fields. /// public void SetHeaderMap(NameValueCollection headers) { var headerMap = cef_string_multimap.From(headers); cef_response_t.set_header_map(_self, headerMap); libcef.string_multimap_free(headerMap); } } }