Headless - SetExtraHTTPHeaders

120 views
Skip to first unread message

Bruce Tompkinson

unread,
Aug 23, 2022, 6:22:39 PM8/23/22
to headless-dev
I am working with Headless Chromium and am attempting to add a cookie to the HTTP request header using network::SetExtraHTTPHeaders. I believe I am setting the header data correctly but I do not see the cookies in the header using wireshark.

Here is how I am setting the cookie data. I've tested setting the cookie data in OnRequestIntercepted, OnRequestWillBeSent, OnResponseRecieved,  and OnDevToolsTargetReady, and basically anywhere I can think of.
std::unique_ptr<base::Value> header_values(new base::Value("TESTCOOKIE=TESTCOOKIEVALUE"));
std::unique_ptr<base::DictionaryValue> headers(new base::DictionaryValue);
headers->Set("Cookie", std::move(header_values));
std::unique_ptr<network::SetExtraHTTPHeadersParams> params = network::SetExtraHTTPHeadersParams::Builder()
      .SetHeaders(std::move(headers))
      .Build();
devtools_client_->GetNetwork()->GetExperimental()->SetExtraHTTPHeaders(std::move(params));

The SetExtraHTTPHeadersParams data appears correct in my logging:
{"headers":{"Cookie":"TESTCOOKIE=TESTCOOKIEVALUE"}}

Wireshark does not show the cookie data in the capture:
Capture.PNG

Can anyone tell me if this is the correct way to set extra HTT headers and if not what I am doing wrong?

Thank you,
Bruce

Jerry Lee Daniel

unread,
Nov 19, 2023, 11:17:53 AM11/19/23
to headless-dev, Bruce Tompkinson

Loans, Project and Digital Investment financing available up to $500m.
Have a Business Plan, Fundable Project and Redeemable Collateral.

Whatsapp: +44 7405 896213
Reply all
Reply to author
Forward
0 new messages