Class HeaderInterceptor

  • All Implemented Interfaces:
    okhttp3.Interceptor

    public class HeaderInterceptor
    extends java.lang.Object
    implements okhttp3.Interceptor
    Interceptor to add headers to any request. This should be used to set authentication or other contextual headers.
    • Nested Class Summary

      • Nested classes/interfaces inherited from interface okhttp3.Interceptor

        okhttp3.Interceptor.Chain
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void add​(java.lang.String key, java.lang.String value)
      Adds a header that will be added to the intercepted request.
      okhttp3.Response intercept​(okhttp3.Interceptor.Chain chain)  
      void remove​(java.lang.String key)
      Removes a header that will no longer be added to the intercepted request.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • HeaderInterceptor

        public HeaderInterceptor()
    • Method Detail

      • intercept

        @Nonnull
        public okhttp3.Response intercept​(okhttp3.Interceptor.Chain chain)
                                   throws java.io.IOException
        Specified by:
        intercept in interface okhttp3.Interceptor
        Throws:
        java.io.IOException
      • add

        public void add​(java.lang.String key,
                        java.lang.String value)
        Adds a header that will be added to the intercepted request.
        Parameters:
        key - name of the header to be added
        value - value of the header to be added
      • remove

        public void remove​(java.lang.String key)
        Removes a header that will no longer be added to the intercepted request.
        Parameters:
        key - name of the header to be removed