
Originally Posted by
WZabel
Now there is my next question: How can request-headers be changed?
The new WebView2Loader-Dlls already have interface-extensions for the
TypeLib-defined ICoreWebView2-interface (two of them):
-> interface ICoreWebView2_2 : ICoreWebView2
-> interface ICoreWebView2_3 : ICoreWebView2_2
And ICoreWebView2_2 comes (among others) with the new method:
HRESULT NavigateWithWebResourceRequest([in] ICoreWebView2WebResourceRequest* request)
Here is the Interface-Def for the new ICoreWebView2WebResourceRequest
(a "Data-Object", which needs to be passed into the above new method)...
Code:
[uuid(97055cd4-512c-4264-8b5f-e3f446cea6a5), object, pointer_default(unique)]
interface ICoreWebView2WebResourceRequest : IUnknown {
/// The request URI.
[propget] HRESULT Uri([out, retval] LPWSTR* uri);
/// Sets the `Uri` property.
[propput] HRESULT Uri([in] LPCWSTR uri);
/// The HTTP request method.
[propget] HRESULT Method([out, retval] LPWSTR* method);
/// Sets the `Method` property.
[propput] HRESULT Method([in] LPCWSTR method);
/// The HTTP request message body as stream. POST data should be here. If a
/// stream is set, which overrides the message body, the stream must have
/// all the content data available by the time the `WebResourceRequested`
/// event deferral of this response is completed. Stream should be agile or
/// be created from a background STA to prevent performance impact to the UI
/// thread. `Null` means no content data. `IStream` semantics apply
/// (return `S_OK` to `Read` runs until all data is exhausted).
[propget] HRESULT Content([out, retval] IStream** content);
/// Sets the `Content` property.
[propput] HRESULT Content([in] IStream* content);
/// The mutable HTTP request headers
[propget] HRESULT Headers([out, retval] ICoreWebView2HttpRequestHeaders** headers);
}
I plan to incorporate support for that kind of "fully user-defined Request" into one of the next releases.
Olaf