miketaylr / user-agent-reduction

This repository is for documenting and discussing all matters related to User Agent Reduction in Chromium.
Other
9 stars 7 forks source link

User-Agent header is not right for 302 direct when chrome devtool is switched to mobile mode. #4

Closed INCHMAN1900 closed 2 years ago

INCHMAN1900 commented 3 years ago

Describe the issue

When in mobile mode, the devtool will send mobile User-Agent header to the server. If the server responds with a 302 redirect, chrome will follow the request to the Location, but with chrome's original User-Agent.

Environment:

To Reproduce

visit this site under mobile mode in devtool.

You'll find two 302 request in the network panel. The first is sent with Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1. The second is sent with Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.54 Safari/537.36

Expected behavior

Both requests are sent with Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1

Screenshots

first request:

截屏2021-10-26 下午5 48 20

second request:

截屏2021-10-26 下午5 48 34

Additional context

chrome 94 is fine. So I suppose this is a problem in chrome 95

abeyad commented 3 years ago

Thanks for the report @INCHMAN1900!

Did you have the User-Agent Reduction origin trial enabled on your site? I don't see signs of having the UA reduction origin trial enabled in your request headers screen shot, but just wanted to confirm. This could be a regression in the User-Agent handling irrespective of whether the origin trial is enabled or not.

INCHMAN1900 commented 3 years ago

Thanks for the report @INCHMAN1900!

Did you have the User-Agent Reduction origin trial enabled on your site? I don't see signs of having the UA reduction origin trial enabled in your request headers screen shot, but just wanted to confirm. This could be a regression in the User-Agent handling irrespective of whether the origin trial is enabled or not.

I've tried to set Reduce User-Agent request header in chrome://flags to true or false, and it doesn't matter.

abeyad commented 3 years ago

Note: This was also reported at https://bugs.chromium.org/p/chromium/issues/detail?id=1263639.

INCHMAN1900 commented 3 years ago

Note: This was also reported at https://bugs.chromium.org/p/chromium/issues/detail?id=1263639.

Thx.

abeyad commented 3 years ago

https://chromium-review.googlesource.com/c/chromium/src/+/3251922 is up, which should fix the issue (tested it manually as well)

abeyad commented 2 years ago

This was fixed for M97: https://chromium-review.googlesource.com/c/chromium/src/+/3251922 And was back-ported to M96: https://chromium-review.googlesource.com/c/chromium/src/+/3258067