MicrosoftEdge / MicrosoftEdge/WebView2Feedback

In some POST transmissions using NavigateWithWebResourceRequest, HTTP headers are not reflected correctly

Open
#2,556 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug tracked
Dominant language
PowerShell
Stars
526
Forks
67
PR merge metrics
No merged PRs in 30d

Description

Description

When sending NavigateWithWebResourceRequest by POST, I want to change the HTTP header and send it, but only three, origin, sec-fetch-site, and referer, are fixed.

origin: null

sec-fetch-site: none

referer is not reflected

Version
SDK: 1.0.1245.22
Runtime:
Framework: Win32(x64)
OS: Win10

Repro Steps

        QString strHeader = QString("content-type: application/x-www-form-urlencoded\r\n"
                                    "cache-control: max-age=0\r\n"
                                    "sec-ch-ua: \" Not;A Brand\";v=\"99\", \"Chromium\";v=\"103\", \"Microsoft Edge\";v=\"103\"\r\n"
                                    "sec-ch-ua-mobile: ?0\r\n"
                                    "sec-ch-ua-platform: \"Windows\"\r\n"
                                    "upgrade-insecure-requests: 1\r\n"
                                    "origin: https://www.google.co.jp\r\n"
                                    "user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.5060.53 Safari/537.36 Edg/103.0.1264.37\r\n"
                                    "accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9\r\n"
                                    "sec-fetch-site: same-origin\r\n"
                                    "sec-fetch-mode: navigate\r\n"
                                    "sec-fetch-user: ?1\r\n"
                                    "sec-fetch-dest: document\r\n"
                                    "referer: https://www.google.co.jp\r\n"
                                    "accept-encoding: gzip, deflate, br\r\n"
                                    "accept-language: ja,en;q=0.9,en-GB;q=0.8,en-US;q=0.7\r\n"
                            );
        CHECK_FAILURE(m_webviewEnvironment2->CreateWebResourceRequest(
            url.toString().toStdWString().c_str(), L"POST", postDataStream.get(),
            strHeader.toStdWString().c_str(), &webResourceRequest));
    wil::com_ptr<ICoreWebView2_2> webView2;
    CHECK_FAILURE(currentWebView()->QueryInterface(IID_PPV_ARGS(&webView2)));
    CHECK_FAILURE(webView2->NavigateWithWebResourceRequest(webResourceRequest.get()));

Screenshots
image

Additional context

AB#41852204

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the supplied Win32 example using CreateWebResourceRequest and NavigateWithWebResourceRequest on the reported SDK and OS. Compare the requested headers with those received by the target server, focusing on origin, sec-fetch-site, and referer. Done means determining whether the behavior is an API defect or documented restriction and recording the supported behavior or a fix path.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
api, desktop-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.