Skip to content

Commit 0887db6

Browse files
author
Çağrı Kaan Yıldırım
authored
Update NavigateWithWebResourceRequest.md
1 parent a3dcb45 commit 0887db6

1 file changed

Lines changed: 13 additions & 10 deletions

File tree

specs/NavigateWithWebResourceRequest.md

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
# Background
3-
Consumers of the old WebBrowser control that relied on the [Navigate](https://docs.microsoft.com/en-us/previous-versions/aa752133(v=vs.85) API that allowed them to specify HTTP POST data and extra headers as part of navigation, [requested](https://github.com/MicrosoftEdge/WebViewFeedback/issues/69) same ability in WebView2.
3+
Consumers of the old WebBrowser control that relied on the [Navigate](https://docs.microsoft.com/en-us/previous-versions/aa752133(v=vs.85)) API that allowed them to specify HTTP POST data and extra headers as part of navigation, [requested](https://github.com/MicrosoftEdge/WebViewFeedback/issues/69) same ability in WebView2.
44

55
# Description
66
We propose adding NavigateWithWebResourceRequest to CoreWebView2 as the API that allows a WebView2 to navigate with a specified [CoreWebView2WebResourceRequest](https://docs.microsoft.com/en-us/microsoft-edge/webview2/reference/dotnet/0-9-628/microsoft-web-webview2-core-corewebview2). This allows the developer to specify extra headers and POST data as part of their request for navigation.
@@ -11,11 +11,16 @@ We also propose adding a CreateWebResourceRequest API to [CoreWebView2Environmen
1111
```cpp
1212
// Need to convert post data to UTF-8 as required by the application/x-www-form-urlencoded Content-Type
1313
std::wstring postData = std::wstring(L"input=Hello");
14-
char* postDataString = new char[postData.length()];
15-
WideCharToMultiByte(
16-
CP_UTF8, 0, postData.c_str(), postData.length(), postDataString, postData.length(),
14+
int sizeNeededForMultiByte = WideCharToMultiByte(
15+
CP_UTF8, 0, postData.c_str(), -1, nullptr,
16+
0,
1717
nullptr, nullptr);
1818

19+
char* postDataString = new char[sizeNeededForMultiByte];
20+
WideCharToMultiByte(
21+
CP_UTF8, 0, postData.c_str(), -1, postDataString, sizeNeededForMultiByte, nullptr,
22+
nullptr);
23+
1924
wil::com_ptr<ICoreWebView2WebResourceRequest> webResourceRequest;
2025
wil::com_ptr<IStream> postDataStream = SHCreateMemStream(
2126
reinterpret_cast<const BYTE*>(postDataString), postData.length());
@@ -65,9 +70,8 @@ with a "///" comment above the member or type. -->
6570
# API Details
6671
<!-- The exact API, in MIDL3 format (https://docs.microsoft.com/en-us/uwp/midl-3/) -->
6772
```idl
68-
// This is the ICoreWebView2 Staging interface.
69-
[uuid(9810c82b-8483-4f1c-b2f4-6244f1010c05), object, pointer_default(unique)]
70-
interface ICoreWebView2Staging : IUnknown {
73+
[uuid(7fbad153-fb94-452e-acab-3cbb9ab341ec), object, pointer_default(unique)]
74+
interface ICoreWebView2_2 : ICoreWebView2 {
7175
....
7276
/// Navigate using a constructed WebResourceRequest object. This let's you
7377
/// provide post data or additional request headers during navigation.
@@ -80,9 +84,8 @@ interface ICoreWebView2Staging : IUnknown {
8084
HRESULT NavigateWithWebResourceRequest([in] ICoreWebView2WebResourceRequest* request);
8185
}
8286
83-
// This is the ICoreWebView2Environment Staging interface.
84-
[uuid(512e6181-6e99-4744-9b75-183fbefb090b), object, pointer_default(unique)]
85-
interface ICoreWebView2StagingEnvironment : IUnknown {
87+
[uuid(1c11735a-d57d-4614-a9e1-8b48d81da38c), object, pointer_default(unique)]
88+
interface ICoreWebView2Environment_2 : IUnknown {
8689
/// Create a new web resource request object.
8790
/// URI parameter must be absolute URI.
8891
/// The headers string is the raw request header string delimited by newline

0 commit comments

Comments
 (0)