Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
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
31 changes: 31 additions & 0 deletions 31 src/main/java/com/github/dockerjava/netty/InvocationBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ public void onNext(T object) {
}
}

public class SkipResultCallback extends ResultCallbackTemplate<ResponseCallback<Void>, Void> {
@Override
public void onNext(Void object) {
}
}

private ChannelProvider channelProvider;

private String resource;
Expand Down Expand Up @@ -401,6 +407,31 @@ public <T> void post(TypeReference<T> typeReference, ResultCallback<T> resultCal
channel.pipeline().addLast(new JsonObjectDecoder());
channel.pipeline().addLast(jsonResponseHandler);

postChunkedStreamRequest(requestProvider, channel, body);
}

public void postStream(InputStream body) {
SkipResultCallback resultCallback = new SkipResultCallback();

HttpRequestProvider requestProvider = httpPostRequestProvider(null);

Channel channel = getChannel();

HttpResponseHandler responseHandler = new HttpResponseHandler(requestProvider, resultCallback);

channel.pipeline().addLast(new ChunkedWriteHandler());
channel.pipeline().addLast(responseHandler);

postChunkedStreamRequest(requestProvider, channel, body);

try {
resultCallback.awaitCompletion();
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}

private void postChunkedStreamRequest(HttpRequestProvider requestProvider, Channel channel, InputStream body) {
HttpRequest request = requestProvider.getHttpRequest(resource);

// don't accept FullHttpRequest here
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.fasterxml.jackson.core.type.TypeReference;
import com.github.dockerjava.api.command.LoadImageCmd;
import com.github.dockerjava.core.DockerClientConfig;
import com.github.dockerjava.netty.WebTarget;
Expand All @@ -22,8 +21,8 @@ protected Void execute(LoadImageCmd command) {
WebTarget webResource = getBaseResource().path("/images/load");

LOGGER.trace("POST: {}", webResource);
return webResource.request()
.post(new TypeReference<Void>() {
}, command.getImageStream());
webResource.request().postStream(command.getImageStream());

return null;
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.