Class CustomTransport
java.lang.Object
cn.ucloud.common.transport.CustomTransport
- All Implemented Interfaces:
Transport,Closeable,AutoCloseable
CustomTransport extends DefaultTransport to support custom HTTP headers
This transport implementation allows adding custom HTTP headers to all requests, which is useful for scenarios like channel identification, custom authentication, etc.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddCustomHeader(String name, String value) Add a custom HTTP header to all requestsvoidclose()Get all custom headersorg.apache.http.impl.client.CloseableHttpClientvoidremoveCustomHeader(String name) Remove a custom HTTP headervoidsetBaseUrl(String baseUrl) voidsetHttpClient(org.apache.http.impl.client.CloseableHttpClient httpClient) voidsetUserAgent(String userAgent)
-
Constructor Details
-
CustomTransport
-
-
Method Details
-
addCustomHeader
-
removeCustomHeader
Remove a custom HTTP header- Parameters:
name- header name
-
getCustomHeaders
-
invoke
- Specified by:
invokein interfaceTransport- Parameters:
request- Request payload with dataclazz- Response class without data- Returns:
- Response
- Throws:
UCloudException- exception
-
getBaseUrl
-
setBaseUrl
-
getUserAgent
-
setUserAgent
-
getHttpClient
public org.apache.http.impl.client.CloseableHttpClient getHttpClient() -
setHttpClient
public void setHttpClient(org.apache.http.impl.client.CloseableHttpClient httpClient) -
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-