Class UserAgent


  • public class UserAgent
    extends Object
    Instances of this class are used to construct the user agent that is used for HTTP requests.

    Additional key/value properties can be registered using register(String, String).

    Since version 4.0.1 this class strips non-ASCII characters from the User-Agent by default. You can disable this behaviour by setting
    Since:
    3.0.0
    • Field Detail

      • STRIP_NON_ASCII_CHARACTERS

        public static boolean STRIP_NON_ASCII_CHARACTERS
        By default, the UserAgent string will be stripped and all non-ASCII characters will be removed. You can set this flag to true to disable the filter. Please note that some HTTP stacks, especially the one used by OkHttp do not allow non-ASCII characters in the User Agent and you will get an Exception if you change the behaviour.
        Since:
        4.0.1
    • Constructor Detail

      • UserAgent

        public UserAgent()
    • Method Detail

      • register

        public static void register​(@NonNull
                                    String key,
                                    @NonNull
                                    String value)
        Register an additional key value pair that will be added to the user agent string representation
        Parameters:
        key - the key
        value - the value