|
|
@@ -1,5 +1,6 @@
|
|
|
package cn.reghao.autodop.common.dockerc.unixdomain;
|
|
|
|
|
|
+import cn.reghao.autodop.common.utils.ExceptionUtil;
|
|
|
import io.netty.buffer.ByteBuf;
|
|
|
import io.netty.buffer.Unpooled;
|
|
|
import io.netty.handler.codec.http.*;
|
|
|
@@ -19,6 +20,15 @@ public class HttpClient {
|
|
|
this.unixSocketClient = unixSocketClient;
|
|
|
}
|
|
|
|
|
|
+ private FullHttpResponse errMsg(Exception e) {
|
|
|
+ FullHttpResponse httpResponse =
|
|
|
+ new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.INTERNAL_SERVER_ERROR);
|
|
|
+ ByteBuf errMsg = Unpooled.buffer(10);
|
|
|
+ errMsg.writeBytes(ExceptionUtil.errorMsg(e).getBytes(StandardCharsets.UTF_8));
|
|
|
+ httpResponse.replace(errMsg);
|
|
|
+ return httpResponse;
|
|
|
+ }
|
|
|
+
|
|
|
public FullHttpResponse get(String uri, List<DockerHeader> headers) {
|
|
|
FullHttpRequest request = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, uri);
|
|
|
request.headers().set(HttpHeaderNames.HOST, "netty");
|