by claudius · 13y ago · 0 comments
In other words, what benefit does a User-Agent field have nowadays when people are told to check for capabilities rather than products, apart from allowing fancy statistics which company currently has the long^Whighest bar in the user agent statistics?
It is unlikely that you will want to block a traditional web browser, but web browsers are not the only clients available and some will be performing operations that are not necessarily in line with the wishes of your resources.
For example, when you let a user download a file, you usually send a header such as:
Content-Disposition: attachment; filename=FILENAME
But what do you do if the filename contains non-ASCII characters? There are RFCs, but every browser has its own rules about encoding, and IE is especially problematic because it tries to second-guess your intentions at every opportunity. You can't use capability detection to solve this problem, because browsers don't execute CSS/JS when they just download files. If you really want to make it perfect for every user, you'll probably need to write a slightly different version of the download script for every browser, and several for IE 6/7/8/9/10.Another valid reason for sniffing the user agent string is when you're trying to offer browser-specific instructions. For example, when you go to Dropbox's download page, they show you how to save and run the installer. They wrote different versions for most of the major browsers/platforms.
There are fewer reasons to use the user agent string when you're just trying to compose a web page. But composing web pages is not the only thing you do when you run a web application.
And even for browser-specific instructions, it would make more sense in my opinion to let users choose the browser for which they want to see instructions[0]: The tool I use to query information is not necessarily the tool I need help with. A bicycle shop also doesn’t decide to only sell shoes or cars if you walk or drive there rather than arriving on a bicycle[1].
[0] I didn’t check Dropbox, so it might well be that they also give people a choice here.
[1] Google’s PlayStore specifically annoyed me there recently as it didn’t let me view the description of an extension in Opera, telling me that I would need Chrome to download and use it – I do, but I’d like to know if this extension is worth installing Chrome or not beforehand.
Of course it's wrong, and web devs wouldn't have to do it in an ideal world. But when your Chinese users complain right now that their attachment names are getting jumbled, and when your conversion rate is going down right now because people don't run the files they've downloaded, does it really matter whose job it is to clean up Microsoft's mess?
BTW, non-ASCII attachment names still come out weird from time to time because Outlook, Thunderbird, and various webmails follow different RFCs. Most email composing tools just use a compromise that works 99.9% of the time, but I've seen programs that let you customize the filename encoding.