CustomHeadersInterceptor Class

  • java.lang.Object
    • com.microsoft.bot.restclient.interceptors.CustomHeadersInterceptor

Implements

okhttp3.Interceptor

public final class CustomHeadersInterceptor
implements okhttp3.Interceptor

An instance of this class enables adding custom headers in client requests when added to the okhttp3.OkHttpClient interceptors.

Constructor Summary

Constructor Description
CustomHeadersInterceptor()

Initialize an instance of CustomHeadersInterceptor class.

CustomHeadersInterceptor(String key, String value)

Initialize an instance of CustomHeadersInterceptor class.

Method Summary

Modifier and Type Method and Description
CustomHeadersInterceptor addHeader(String name, String value)

Add a single header key-value pair.

CustomHeadersInterceptor addHeaderMap(Map<String,String> headers)

Add all headers in a header map.

CustomHeadersInterceptor addHeaderMultimap(Map<String,List<String>> headers)

Add all headers in a header multimap.

CustomHeadersInterceptor addHeaders(Headers headers)

Add all headers in a Headers object.

java.util.Map<java.lang.String,java.util.List<java.lang.String>> headers()
okhttp3.Response intercept(Interceptor.Chain chain)
CustomHeadersInterceptor removeHeader(String name)

Remove a header.

CustomHeadersInterceptor replaceHeader(String name, String value)

Add a single header key-value pair.

Methods inherited from java.lang.Object

java.lang.Object.clone java.lang.Object.equals java.lang.Object.finalize java.lang.Object.getClass java.lang.Object.hashCode java.lang.Object.notify java.lang.Object.notifyAll java.lang.Object.toString java.lang.Object.wait java.lang.Object.wait java.lang.Object.wait

Constructor Details

CustomHeadersInterceptor

public CustomHeadersInterceptor()

Initialize an instance of CustomHeadersInterceptor class.

CustomHeadersInterceptor

public CustomHeadersInterceptor(String key, String value)

Initialize an instance of CustomHeadersInterceptor class.

Parameters:

key - the key for the header
value - the value of the header

Method Details

addHeader

public CustomHeadersInterceptor addHeader(String name, String value)

Add a single header key-value pair. If one with the name already exists, both stay in the header map.

Parameters:

name - the name of the header.
value - the value of the header.

Returns:

the interceptor instance itself.

addHeaderMap

public CustomHeadersInterceptor addHeaderMap(Map headers)

Add all headers in a header map.

Parameters:

headers - a map of headers.

Returns:

the interceptor instance itself.

addHeaderMultimap

public CustomHeadersInterceptor addHeaderMultimap(Map> headers)

Add all headers in a header multimap.

Parameters:

headers - a multimap of headers.

Returns:

the interceptor instance itself.

addHeaders

public CustomHeadersInterceptor addHeaders(Headers headers)

Add all headers in a Headers object.

Parameters:

headers - an OkHttp Headers object.

Returns:

the interceptor instance itself.

headers

public Map> headers()

Returns:

the currently stored custom headers

intercept

public Response intercept(Interceptor.Chain chain)

Parameters:

chain

Throws:

java.io.IOException

removeHeader

public CustomHeadersInterceptor removeHeader(String name)

Remove a header.

Parameters:

name - the name of the header to remove.

Returns:

the interceptor instance itself.

replaceHeader

public CustomHeadersInterceptor replaceHeader(String name, String value)

Add a single header key-value pair. If one with the name already exists, it gets replaced.

Parameters:

name - the name of the header.
value - the value of the header.

Returns:

the interceptor instance itself.

Applies to