Class UserAgentInterceptor

  • All Implemented Interfaces:
    okhttp3.Interceptor

    public final class UserAgentInterceptor
    extends Object
    implements okhttp3.Interceptor
    User agent interceptor for putting a 'User-Agent' header in the request.
    • Constructor Detail

      • UserAgentInterceptor

        public UserAgentInterceptor()
        Initialize an instance of UserAgentInterceptor class with the default 'User-Agent' header.
    • Method Detail

      • withUserAgent

        public UserAgentInterceptor withUserAgent​(String userAgent)
        Overwrite the User-Agent header.
        Parameters:
        userAgent - the new user agent value.
        Returns:
        the user agent interceptor itself
      • appendUserAgent

        public UserAgentInterceptor appendUserAgent​(String userAgent)
        Append a text to the User-Agent header.
        Parameters:
        userAgent - the user agent value to append.
        Returns:
        the user agent interceptor itself
      • userAgent

        public String userAgent()
        Returns:
        the current user agent string.
      • intercept

        public okhttp3.Response intercept​(okhttp3.Interceptor.Chain chain)
                                   throws IOException
        Specified by:
        intercept in interface okhttp3.Interceptor
        Throws:
        IOException