@@ -12,14 +12,13 @@ We also propose adding a CreateWebResourceRequest API to [CoreWebView2Environmen
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" );
1414 int sizeNeededForMultiByte = WideCharToMultiByte(
15- CP_UTF8, 0 , postData.c_str(), -1 , nullptr ,
16- 0 ,
17- nullptr , nullptr );
15+ CP_UTF8, 0 , postData.c_str(), postData.size(), nullptr ,
16+ 0 , nullptr , nullptr );
1817
19- char * postDataString = new char [sizeNeededForMultiByte] ;
18+ std::unique_ptr< char []> postDataBytes = std::make_unique< char []>(sizeNeededForMultiByte) ;
2019 WideCharToMultiByte (
21- CP_UTF8, 0, postData.c_str(), -1, postDataString, sizeNeededForMultiByte, nullptr ,
22- nullptr);
20+ CP_UTF8, 0, postData.c_str(), postData.size(), postDataBytes.get() ,
21+ sizeNeededForMultiByte, nullptr, nullptr);
2322
2423 wil::com_ptr<ICoreWebView2WebResourceRequest> webResourceRequest;
2524 wil::com_ptr<IStream> postDataStream = SHCreateMemStream(
@@ -76,8 +75,7 @@ interface ICoreWebView2_2 : ICoreWebView2 {
7675 /// Navigate using a constructed WebResourceRequest object. This lets you
7776 /// provide post data or additional request headers during navigation.
7877 /// The headers in the WebResourceRequest override headers
79- /// added by WebView2 runtime except for Cookie headers. To override cookies
80- /// please use the Cookie API.
78+ /// added by WebView2 runtime except for Cookie headers.
8179 /// Method can only be either "GET" or "POST". Provided post data will only
8280 /// be sent only if the method is "POST" and the uri scheme is HTTP(S).
8381 /// \snippet ScenarioNavigateWithWebResourceRequest.cpp NavigateWithWebResourceRequest
@@ -88,8 +86,9 @@ interface ICoreWebView2_2 : ICoreWebView2 {
8886interface ICoreWebView2Environment_2 : ICoreWebView2Environment {
8987 /// Create a new web resource request object.
9088 /// URI parameter must be absolute URI.
91- /// The headers string is the raw request header string delimited by newline
92- /// (\r\n). It's also possible to create this object with null headers string
89+ /// The headers string is the raw request header string delimited by CRLF
90+ /// (optional in last header).
91+ /// It's also possible to create this object with null headers string
9392 /// and then use the ICoreWebView2HttpRequestHeaders to construct the headers
9493 /// line by line.
9594 /// For information on other parameters see ICoreWebView2WebResourceRequest.
@@ -111,9 +110,10 @@ namespace Microsoft.Web.WebView2.Core
111110 ...
112111 /// Create a new web resource request object.
113112 /// URI parameter must be absolute URI.
114- /// The headers string is the raw request header string delimited by newline
115- /// (\r\n). It's also possible to create this object with null headers string
116- /// and then use the ICoreWebView2HttpRequestHeaders to construct the headers
113+ /// The headers string is the raw request header string delimited by CRLF
114+ /// (optional in last header).
115+ /// It's also possible to create this object with null headers string
116+ /// and then use the CoreWebView2HttpRequestHeaders to construct the headers
117117 /// line by line.
118118 /// For information on other parameters see ICoreWebView2WebResourceRequest.
119119 ///
@@ -128,8 +128,7 @@ namespace Microsoft.Web.WebView2.Core
128128 /// Navigate using a constructed WebResourceRequest object. This let's you
129129 /// provide post data or additional request headers during navigation.
130130 /// The headers in the WebResourceRequest override headers
131- /// added by WebView2 runtime except for Cookie headers. To override cookies
132- /// please use the Cookie API.
131+ /// added by WebView2 runtime except for Cookie headers.
133132 /// Method can only be either "GET" or "POST". Provided post data will only
134133 /// be sent only if the method is "POST" and the uri scheme is HTTP(S).
135134 public void NavigateWithWebResourceRequest (CoreWebView2WebResourceRequest request );
0 commit comments