Package com.alibaba.dashscope.transport
Class HttpTransport
java.lang.Object
com.alibaba.dashscope.transport.HttpTransport
- All Implemented Interfaces:
AutoCloseable
3.0 HTTP transport (design §6): one OkHttpClient (pool maxRequests=100 / perHost=20, keepAlive
5s, env-tunable), application-level retry/auth/UA interceptors, and the dual error layer —
non-2xx status and HTTP-200-with-business-code both map through
Errors; with
raiseOnError(false) they instead surface on the returned envelope (2.x-style isError()
semantics). Network failures always raise.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()config()derive(ResolvedConfig newConfig) Derive a transport reusing this one's connection pool (design §2 withOptions) — unless the override injects a differentOkHttpClient, which is honored by deriving from it (sharing its pool, with interceptors ensured by the constructor).execute(String path, com.fasterxml.jackson.databind.JsonNode body, String module, RequestOptions options) POSTpath(relative to the resolved base URL) with a JSON body.execute(String path, com.fasterxml.jackson.databind.JsonNode body, Map<String, String> extraHeaders, String module, RequestOptions options) POST with extra request headers (e.g.executeDelete(String path, String module, RequestOptions options) DELETEpath(files/fine-tunes/deployments CRUD).executeForm(String path, Map<String, String> fields, String fileField, String fileName, byte[] content, String contentType, String module, RequestOptions options) Multipart POST (files upload): form fields first, the file part last; rides the same auth/retry/UA pipeline as JSON posts.executeGet(String path, Map<String, String> query, String module, RequestOptions options) GETpathwith query parameters (jobs fetch/cancel/list).executeJobEventStream(String path, String module, RequestOptions options) GET a job-event SSE endpoint (fine-tunes/deployments): theevent:error/status:framing, not the plaindata:-only shape ofexecuteStream(java.lang.String, com.fasterxml.jackson.databind.JsonNode, java.lang.String, com.alibaba.dashscope.RequestOptions).executePut(String path, com.fasterxml.jackson.databind.JsonNode body, String module, RequestOptions options) PUTpathwith a JSON body (deployments scale).executeStream(String path, com.fasterxml.jackson.databind.JsonNode body, String module, RequestOptions options) POST with SSE: returns the open stream.executeStream(String path, com.fasterxml.jackson.databind.JsonNode body, String module, String userAgentSuffix, RequestOptions options) SSE variant carrying a User-Agent suffix (multimodal incremental_to_full parity).okhttp3.OkHttpClientokhttp()The shared OkHttpClient (same pool + auth/UA/retry interceptors); used by the ws transport.
-
Constructor Details
-
HttpTransport
-
-
Method Details
-
derive
Derive a transport reusing this one's connection pool (design §2 withOptions) — unless the override injects a differentOkHttpClient, which is honored by deriving from it (sharing its pool, with interceptors ensured by the constructor). -
config
-
okhttp
public okhttp3.OkHttpClient okhttp()The shared OkHttpClient (same pool + auth/UA/retry interceptors); used by the ws transport. -
execute
public ResponseEnvelope execute(String path, com.fasterxml.jackson.databind.JsonNode body, String module, RequestOptions options) POSTpath(relative to the resolved base URL) with a JSON body. -
executePut
public ResponseEnvelope executePut(String path, com.fasterxml.jackson.databind.JsonNode body, String module, RequestOptions options) PUTpathwith a JSON body (deployments scale). -
execute
public ResponseEnvelope execute(String path, com.fasterxml.jackson.databind.JsonNode body, Map<String, String> extraHeaders, String module, RequestOptions options) POST with extra request headers (e.g.X-DashScope-Async: enablefor job submit). -
executeGet
public ResponseEnvelope executeGet(String path, Map<String, String> query, String module, RequestOptions options) GETpathwith query parameters (jobs fetch/cancel/list). -
executeDelete
DELETEpath(files/fine-tunes/deployments CRUD). -
executeForm
public ResponseEnvelope executeForm(String path, Map<String, String> fields, String fileField, String fileName, byte[] content, String contentType, String module, RequestOptions options) Multipart POST (files upload): form fields first, the file part last; rides the same auth/retry/UA pipeline as JSON posts. Bytes, not a live handle: transport retries must be able to re-send the full body. -
executeStream
public SseStream executeStream(String path, com.fasterxml.jackson.databind.JsonNode body, String module, RequestOptions options) POST with SSE: returns the open stream. The initial HTTP layer always raises on failure (there is no response object to hand back); in-stream error frames follow raiseOnError. -
executeStream
public SseStream executeStream(String path, com.fasterxml.jackson.databind.JsonNode body, String module, String userAgentSuffix, RequestOptions options) SSE variant carrying a User-Agent suffix (multimodal incremental_to_full parity). -
executeJobEventStream
GET a job-event SSE endpoint (fine-tunes/deployments): theevent:error/status:framing, not the plaindata:-only shape ofexecuteStream(java.lang.String, com.fasterxml.jackson.databind.JsonNode, java.lang.String, com.alibaba.dashscope.RequestOptions). The initial HTTP layer always raises on failure. -
close
public void close()- Specified by:
closein interfaceAutoCloseable
-