Skip to content
This repository was archived by the owner on Nov 13, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
119 changes: 0 additions & 119 deletions engine/src/main/java/de/gesellix/docker/engine/AttachConfig.java

This file was deleted.

13 changes: 2 additions & 11 deletions engine/src/main/java/de/gesellix/docker/engine/EngineRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public class EngineRequest {
private int timeout = 0;

private boolean async = false;
private AttachConfig attach = null;
private OutputStream stdout;

private String apiVersion = null;
Expand Down Expand Up @@ -93,14 +92,6 @@ public void setAsync(boolean async) {
this.async = async;
}

public AttachConfig getAttach() {
return attach;
}

public void setAttach(AttachConfig attach) {
this.attach = attach;
}

public OutputStream getStdout() {
return stdout;
}
Expand All @@ -124,11 +115,11 @@ public boolean equals(Object o) {
EngineRequest that = (EngineRequest) o;
return timeout == that.timeout && async == that.async && method == that.method && Objects.equals(path, that.path) && Objects.equals(headers, that.headers) &&
Objects.equals(query, that.query) && Objects.equals(contentType, that.contentType) && Objects.equals(body, that.body) &&
Objects.equals(attach, that.attach) && Objects.equals(stdout, that.stdout) && Objects.equals(apiVersion, that.apiVersion);
Objects.equals(stdout, that.stdout) && Objects.equals(apiVersion, that.apiVersion);
}

@Override
public int hashCode() {
return Objects.hash(method, path, headers, query, contentType, body, timeout, async, attach, stdout, apiVersion);
return Objects.hash(method, path, headers, query, contentType, body, timeout, async, stdout, apiVersion);
}
}
57 changes: 12 additions & 45 deletions engine/src/main/java/de/gesellix/docker/engine/OkDockerClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
import de.gesellix.docker.client.filesocket.NamedPipeSocketFactory;
import de.gesellix.docker.client.filesocket.UnixSocketFactory;
import de.gesellix.docker.client.filesocket.UnixSocketFactorySupport;
import de.gesellix.docker.hijack.HijackingInterceptor;
import de.gesellix.docker.hijack.OkResponseCallback;
import de.gesellix.docker.json.CustomObjectAdapterFactory;
import de.gesellix.docker.rawstream.RawInputStream;
import de.gesellix.docker.response.JsonContentHandler;
Expand Down Expand Up @@ -148,60 +146,30 @@ public WebSocket webSocket(Map<String, Object> requestConfig, WebSocketListener
public EngineResponse request(EngineRequest requestConfig) {
EngineRequest config = ensureValidRequestConfig(requestConfig);

AttachConfig attachConfig = null;
if (config.getAttach() != null) {
Map<String, String> headers = config.getHeaders();
if (headers == null) {
headers = new HashMap<>();
}
config.setHeaders(headers);
// https://docs.docker.com/engine/api/v1.41/#operation/ContainerAttach
// To hint potential proxies about connection hijacking, the Docker client sends connection upgrade headers.
headers.put("Upgrade", "tcp");
headers.put("Connection", "Upgrade");
attachConfig = config.getAttach();
}
// boolean multiplexStreams = config.multiplexStreams

Request.Builder requestBuilder = prepareRequest(new Request.Builder(), config);
final Request request = requestBuilder.build();

OkHttpClient.Builder clientBuilder = prepareClient(new OkHttpClient.Builder(), config.getTimeout());
OkResponseCallback responseCallback = null;
if (attachConfig != null) {
clientBuilder.addNetworkInterceptor(new HijackingInterceptor(
attachConfig,
attachConfig.getStreams().getStdin() == null ? null : Okio.source(attachConfig.getStreams().getStdin()),
attachConfig.getStreams().getStdout() == null ? null : Okio.sink(attachConfig.getStreams().getStdout())));
responseCallback = new OkResponseCallback(attachConfig);
}
final OkHttpClient client = newClient(clientBuilder);

log.debug(request.method() + " " + request.url() + " using proxy: " + client.proxy());

Call call = client.newCall(request);
if (responseCallback != null) {
call.enqueue(responseCallback);
log.debug("request enqueued");
return new EngineResponse<Void>();
}
else {
EngineResponse dockerResponse;
try {
Response response = call.execute();
log.debug("response: " + response);
dockerResponse = handleResponse(response, config);
if (dockerResponse.getStream() == null) {
EngineResponse dockerResponse;
try {
Response response = call.execute();
log.debug("response: " + response);
dockerResponse = handleResponse(response, config);
if (dockerResponse.getStream() == null) {
// log.warn("closing response...");
response.close();
}
}
catch (Exception e) {
log.error("Request failed", e);
throw new RuntimeException("Request failed", e);
response.close();
}
return dockerResponse;
}
catch (Exception e) {
log.error("Request failed", e);
throw new RuntimeException("Request failed", e);
}
return dockerResponse;
}

private Request.Builder prepareRequest(final Request.Builder builder, final EngineRequest config) {
Expand Down Expand Up @@ -526,7 +494,6 @@ private EngineRequest ensureValidRequestConfig(final Map<String, Object> config,
engineRequest.setBody(config.get("body"));

engineRequest.setAsync(config.get("async") != null && (Boolean) config.get("async"));
engineRequest.setAttach((AttachConfig) config.get("attach"));
engineRequest.setStdout((OutputStream) config.get("stdout"));

engineRequest.setApiVersion((String) config.get("apiVersion"));
Expand Down

This file was deleted.

Loading
Loading