public final class CustomHeadersInterceptor extends Object implements okhttp3.Interceptor
OkHttpClient
interceptors.Constructor and Description |
---|
CustomHeadersInterceptor()
Initialize an instance of
CustomHeadersInterceptor class. |
CustomHeadersInterceptor(String key,
String value)
Initialize an instance of
CustomHeadersInterceptor class. |
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(okhttp3.Headers headers)
Add all headers in a
Headers object. |
Map<String,List<String>> |
headers() |
okhttp3.Response |
intercept(okhttp3.Interceptor.Chain chain) |
CustomHeadersInterceptor |
removeHeader(String name)
Remove a header.
|
CustomHeadersInterceptor |
replaceHeader(String name,
String value)
Add a single header key-value pair.
|
public CustomHeadersInterceptor()
CustomHeadersInterceptor
class.public CustomHeadersInterceptor(String key, String value)
CustomHeadersInterceptor
class.key
- the key for the headervalue
- the value of the headerpublic CustomHeadersInterceptor replaceHeader(String name, String value)
name
- the name of the header.value
- the value of the header.public CustomHeadersInterceptor addHeader(String name, String value)
name
- the name of the header.value
- the value of the header.public CustomHeadersInterceptor addHeaders(okhttp3.Headers headers)
Headers
object.headers
- an OkHttp Headers
object.public CustomHeadersInterceptor addHeaderMap(Map<String,String> headers)
headers
- a map of headers.public CustomHeadersInterceptor addHeaderMultimap(Map<String,List<String>> headers)
headers
- a multimap of headers.public CustomHeadersInterceptor removeHeader(String name)
name
- the name of the header to remove.public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException
intercept
in interface okhttp3.Interceptor
IOException
Copyright © 2019. All rights reserved.