Core - Add IResponse.SetHeaderByName/GetHeaderByName

This commit is contained in:
Alex Maitland
2020-11-26 16:43:16 +10:00
parent 80753ebc70
commit 6991d0e53c
2 changed files with 32 additions and 0 deletions
@@ -180,6 +180,21 @@ namespace CefSharp
}
}
virtual String^ GetHeaderByName(String^ name)
{
ThrowIfDisposed();
return StringUtils::ToClr(_response->GetHeaderByName(StringUtils::ToNative(name)));
}
virtual void SetHeaderByName(String^ name, String^ value, bool overwrite)
{
ThrowIfDisposed();
ThrowIfReadOnly();
_response->SetHeaderByName(StringUtils::ToNative(name), StringUtils::ToNative(value), overwrite);
}
void ThrowIfReadOnly()
{
if (_response->IsReadOnly())
+17
View File
@@ -47,5 +47,22 @@ namespace CefSharp
/// Status Text
/// </summary>
string StatusText { get; set; }
/// <summary>
/// Returns the first header value for name or an empty string if not found.
/// Will not return the Referer value if any. Use <see cref="Headers"/> instead if name might have multiple values.
/// </summary>
/// <param name="name">header name</param>
/// <returns>Returns the first header value for name or an empty string if not found.</returns>
string GetHeaderByName(string name);
/// <summary>
/// Set the header name to value. The Referer value cannot be set using this method.
/// Use <see cref="SetReferrer(string, ReferrerPolicy)"/> instead.
/// </summary>
/// <param name="name">header name</param>
/// <param name="value">new header value</param>
/// <param name="overwrite">If overwrite is true any existing values will be replaced with the new value. If overwrite is false any existing values will not be overwritten</param>
void SetHeaderByName(string name, string value, bool overwrite);
}
}