It's nearly always a bad idea to do UA sniffing. You can't rely on it at all.
If you want to sent the client a response specific to its environment you should perhaps distinguish differences from content-type or encoding. These are rock-solid specified.