Javascript user-agent (ajax) different to sent user-agent when requesting website

前端 未结 2 801
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-02 09:34

I noticed that Chrome (64.0.3282.137) on my phone (OnePlus 3, Android 8.0.0) sends slightly different user-agents when requesting a webpage in contrast to requesting via ajax.

2条回答
  •  萌比男神i
    2021-02-02 10:33

    In the first userAgent, the browser identifies the device as a mobile device by modifying the userAgent before making the request; hence the ONEPLUS A3003. In the second however, due w3 specification (Find it here), you cannot modify the userAgent; hence the omission of ONEPLUS A3003.

    When you use the "Request desktop site" feature, there is no need for modification of userAgent by the browser, hence you get the same userAgent.

    NOTE: That the default userAgent for that Chrome browser is: Mozilla/5.0 (Linux; Android 8.0.0; Build/OPR6.170623.013) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.137 Mobile Safari/537.36

提交回复
热议问题