sitespeedio / chrome-har

Create HAR files from Chrome Debugging Protocol data
MIT License
150 stars 50 forks source link

Response set-cookie header didn't align with chrome/firefox exported har #121

Open ifduyue opened 3 months ago

ifduyue commented 3 months ago

chrome-har behavior (note the \n):

            {
              "name": "set-cookie",
              "value": ".MSA.Auth=; expires=Thu, 01 Jan 1970 00:00:00 GMT; max-age=0; domain=.bing.com; path=/; secure; samesite=lax; httponly\nMUIDB=27EF5FA852976BB80EDC4B1153CD6A16; expires=Tue, 05-Aug-2025 04:00:54 GMT; path=/; HttpOnly"
            },

chrome/firefox exported har behavior:

            {
              "name": "set-cookie",
              "value": ".MSA.Auth=; expires=Thu, 01 Jan 1970 00:00:00 GMT; max-age=0; domain=.bing.com; path=/; secure; samesite=lax; httponly"
            },
            {
              "name": "set-cookie",
              "value": "MUIDB=27EF5FA852976BB80EDC4B1153CD6A16; expires=Tue, 05-Aug-2025 04:00:54 GMT; path=/; HttpOnly"
            },

If it's OK I can submit a PR

soulgalore commented 3 months ago

Hi @ifduyue aha ok, yes please if you have the time do the PR :)

ifduyue commented 3 months ago

Things become more complex. I've found the Network.responseReceivedExtraInfo event can occur twice for a single requestId:

$ cat test/perflogs/bing.com.json | jq '.[] | select(.params.requestId == "DC2DB00F1A4F0A391C48E404FF168637" and .method == "Network.responseReceivedExtraInfo")'
{
  "method": "Network.responseReceivedExtraInfo",
  "params": {
    "requestId": "DC2DB00F1A4F0A391C48E404FF168637",
    "blockedCookies": [],
    "headers": {
      "accept-ch": "Sec-CH-UA-Arch, Sec-CH-UA-Bitness, Sec-CH-UA-Full-Version, Sec-CH-UA-Full-Version-List, Sec-CH-UA-Mobile, Sec-CH-UA-Model, Sec-CH-UA-Platform, Sec-CH-UA-Platform-Version",
      "content-length": "0",
      "date": "Thu, 11 Jul 2024 04:00:51 GMT",
      "location": "https://cn.bing.com/",
      "x-msedge-ref": "Ref A: 1609281457634F55ABA9F86E69014FCD Ref B: SIN30EDGE0713 Ref C: 2024-07-11T04:00:51Z"
    },
    "resourceIPAddressSpace": "Public",
    "statusCode": 301,
    "cookiePartitionKey": "https://bing.com",
    "cookiePartitionKeyOpaque": false,
    "exemptedCookies": []
  }
}
{
  "method": "Network.responseReceivedExtraInfo",
  "params": {
    "requestId": "DC2DB00F1A4F0A391C48E404FF168637",
    "blockedCookies": [],
    "headers": {
      "accept-ch": "Sec-CH-UA-Bitness, Sec-CH-UA-Arch, Sec-CH-UA-Full-Version, Sec-CH-UA-Mobile, Sec-CH-UA-Model, Sec-CH-UA-Platform-Version, Sec-CH-UA-Full-Version-List, Sec-CH-UA-Platform, Sec-CH-UA, UA-Bitness, UA-Arch, UA-Full-Version, UA-Mobile, UA-Model, UA-Platform-Version, UA-Platform, UA",
      "cache-control": "private",
      "content-encoding": "br",
      "content-security-policy-report-only": "script-src https: 'strict-dynamic' 'report-sample' 'nonce-HYeJ5O2HRRtyPpaukWHYatV9evY2K7EQ2TXxFX7o/ys='; base-uri 'self';report-to csp-endpoint",
      "content-type": "text/html; charset=utf-8",
      "cross-origin-embedder-policy-report-only": "'same-origin; report-to=\\\"crossorigin-errors\\\"'",
      "cross-origin-opener-policy-report-only": "'require-corp; report-to=\\\"crossorigin-errors\\\"'",
      "date": "Thu, 11 Jul 2024 04:00:52 GMT",
      "nel": "{\"report_to\":\"network-errors\",\"max_age\":604800,\"success_fraction\":0.01,\"failure_fraction\":1.0,\"include_subdomains\":true}",
      "p3p": "CP=\"NON UNI COM NAV STA LOC CURa DEVa PSAa PSDa OUR IND\"",
      "report-to": "{\"group\":\"csp-endpoint\",\"max_age\":86400,\"endpoints\":[{\"url\":\"https://aefd.nelreports.net/api/report?cat=bingcsp\"}]}\n{\"group\":\"network-errors\",\"max_age\":604800,\"endpoints\":[{\"url\":\"https://aefd.nelreports.net/api/report?cat=binghp&ndcParam=QUZE\"}]}\n{\"group\":\"crossorigin-errors\",\"max_age\":604800,\"endpoints\":[{\"url\":\"https://aefd.nelreports.net/api/report?cat=binghp\"}]}",
      "set-cookie": "MUID=27EF5FA852976BB80EDC4B1153CD6A16; domain=.bing.com; expires=Tue, 05-Aug-2025 04:00:52 GMT; path=/; secure; SameSite=None\nMUIDB=27EF5FA852976BB80EDC4B1153CD6A16; expires=Tue, 05-Aug-2025 04:00:52 GMT; path=/; HttpOnly\n_EDGE_S=F=1&SID=33B9E8440A736F860399FCFD0B296E85; domain=.bing.com; path=/; HttpOnly\n_EDGE_V=1; domain=.bing.com; expires=Tue, 05-Aug-2025 04:00:52 GMT; path=/; HttpOnly\nSRCHD=AF=NOFORM; domain=.bing.com; expires=Sat, 11-Jul-2026 04:00:52 GMT; path=/; secure; SameSite=None\nSRCHUID=V=2&GUID=DABD9AEFD0EF404A97FAEEAF01A37C24&dmnchg=1; domain=.bing.com; expires=Sat, 11-Jul-2026 04:00:52 GMT; path=/; secure; SameSite=None\nSRCHUSR=DOB=20240711; domain=.bing.com; expires=Sat, 11-Jul-2026 04:00:52 GMT; path=/; secure; SameSite=None\nSRCHHPGUSR=SRCHLANG=zh-Hans; domain=.bing.com; expires=Sat, 11-Jul-2026 04:00:52 GMT; path=/; secure; SameSite=None\n_SS=SID=33B9E8440A736F860399FCFD0B296E85; domain=.bing.com; path=/; secure; SameSite=None\nULC=; domain=.bing.com; expires=Wed, 10-Jul-2024 04:00:52 GMT; path=/; secure; SameSite=None\n_HPVN=CS=eyJQbiI6eyJDbiI6MSwiU3QiOjAsIlFzIjowLCJQcm9kIjoiUCJ9LCJTYyI6eyJDbiI6MSwiU3QiOjAsIlFzIjowLCJQcm9kIjoiSCJ9LCJReiI6eyJDbiI6MSwiU3QiOjAsIlFzIjowLCJQcm9kIjoiVCJ9LCJBcCI6dHJ1ZSwiTXV0ZSI6dHJ1ZSwiTGFkIjoiMjAyNC0wNy0xMVQwMDowMDowMFoiLCJJb3RkIjowLCJHd2IiOjAsIlRucyI6MCwiRGZ0IjpudWxsLCJNdnMiOjAsIkZsdCI6MCwiSW1wIjoxLCJUb2JuIjowfQ==; domain=.bing.com; expires=Sat, 11-Jul-2026 04:00:52 GMT; path=/; secure; SameSite=None",
      "strict-transport-security": "max-age=31536000; includeSubDomains; preload",
      "useragentreductionoptout": "A7kgTC5xdZ2WIVGZEfb1hUoNuvjzOZX3VIV/BA6C18kQOOF50Q0D3oWoAm49k3BQImkujKILc7JmPysWk3CSjwUAAACMeyJvcmlnaW4iOiJodHRwczovL3d3dy5iaW5nLmNvbTo0NDMiLCJmZWF0dXJlIjoiU2VuZEZ1bGxVc2VyQWdlbnRBZnRlclJlZHVjdGlvbiIsImV4cGlyeSI6MTY4NDg4NjM5OSwiaXNTdWJkb21haW4iOnRydWUsImlzVGhpcmRQYXJ0eSI6dHJ1ZX0=",
      "vary": "Accept-Encoding",
      "x-cache": "CONFIG_NOCACHE",
      "x-eventid": "668f58f4344c408485a7b4dd43ff3eb2",
      "x-frame-options": "SAMEORIGIN",
      "x-msedge-ref": "Ref A: 351DD2522E4840C084FF9580C229307E Ref B: SIN30EDGE0713 Ref C: 2024-07-11T04:00:52Z"
    },
    "resourceIPAddressSpace": "Public",
    "statusCode": 200,
    "cookiePartitionKey": "https://bing.com",
    "cookiePartitionKeyOpaque": false,
    "exemptedCookies": []
  }
}