mirror of
https://github.com/cefsharp/CefSharp.git
synced 2026-12-05 11:42:36 +00:00
IRequest - Add GetHeaderByName and SetHeaderByName
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user