IRequest - Add GetHeaderByName and SetHeaderByName

This commit is contained in:
amaitland
2019-06-18 17:45:19 +10:00
committed by Alex Maitland
parent 8fc2a37a30
commit 3f820e4513
3 changed files with 34 additions and 0 deletions
@@ -173,5 +173,19 @@ namespace CefSharp
_wrappedRequest->SetPostData(CefPostData::Create());
}
String^ CefRequestWrapper::GetHeaderByName(String^ name)
{
ThrowIfDisposed();
return StringUtils::ToClr(_wrappedRequest->GetHeaderByName(StringUtils::ToNative(name)));
}
void CefRequestWrapper::SetHeaderByName(String^ name, String^ value, bool overwrite)
{
ThrowIfDisposed();
_wrappedRequest->SetHeaderByName(StringUtils::ToNative(name), StringUtils::ToNative(value), overwrite);
}
}
}
@@ -54,6 +54,9 @@ namespace CefSharp
virtual property bool IsReadOnly { bool get(); }
virtual void InitializePostData();
virtual String^ GetHeaderByName(String^ name);
virtual void SetHeaderByName(String^ name, String^ value, bool overwrite);
operator CefRefPtr<CefRequest>()
{
if (this == nullptr)
+17
View File
@@ -98,5 +98,22 @@ namespace CefSharp
/// before calling otherwise the existing data will be overridden.
/// </summary>
void InitializePostData();
/// <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);
}
}