Class HeaderInterceptor

java.lang.Object
org.shakespeareframework.retrofit.HeaderInterceptor
All Implemented Interfaces:
okhttp3.Interceptor

public class HeaderInterceptor extends 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, okhttp3.Interceptor.Companion
  • Field Summary

    Fields inherited from interface okhttp3.Interceptor

    Companion
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add(String key, String value)
    Adds a header that will be added to the intercepted request.
    okhttp3.Response
    intercept(okhttp3.Interceptor.Chain chain)
     
    void
    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 Details

    • HeaderInterceptor

      public HeaderInterceptor()
  • Method Details

    • intercept

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

      public void add(String key, 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(String key)
      Removes a header that will no longer be added to the intercepted request.
      Parameters:
      key - name of the header to be removed