use of io.servicecomb.common.rest.codec.param.RestClientRequestImpl in project java-chassis by ServiceComb.
the class VertxHttpMethod method doMethod.
public void doMethod(HttpClientWithContext httpClientWithContext, Invocation invocation, AsyncResponse asyncResp) throws Exception {
OperationMeta operationMeta = invocation.getOperationMeta();
RestOperationMeta swaggerRestOperation = operationMeta.getExtData(RestConst.SWAGGER_REST_OPERATION);
String path = this.createRequestPath(invocation, swaggerRestOperation);
IpPort ipPort = (IpPort) invocation.getEndpoint().getAddress();
HttpClientRequest clientRequest = this.createRequest(httpClientWithContext.getHttpClient(), invocation, ipPort, path, swaggerRestOperation, asyncResp);
RestClientRequestImpl restClientRequest = new RestClientRequestImpl(clientRequest);
RestCodec.argsToRest(invocation.getArgs(), swaggerRestOperation, restClientRequest);
clientRequest.exceptionHandler(e -> {
LOGGER.error(e.toString());
asyncResp.fail(invocation.getInvocationType(), e);
});
// 从业务线程转移到网络线程中去发送
httpClientWithContext.runOnContext(httpClient -> {
this.setCseContext(invocation, clientRequest);
clientRequest.setTimeout(AbstractTransport.getRequestTimeout());
try {
restClientRequest.end();
} catch (Exception e) {
LOGGER.error("send http reqeust failed,", e);
asyncResp.fail(invocation.getInvocationType(), e);
}
});
}
use of io.servicecomb.common.rest.codec.param.RestClientRequestImpl in project java-chassis by ServiceComb.
the class TestParam method setup.
@Before
public void setup() {
request = new MockUp<HttpClientRequest>() {
@Mock
public HttpClientRequest putHeader(CharSequence name, CharSequence value) {
this.putHeader(name.toString(), value.toString());
return request;
}
@Mock
public HttpClientRequest putHeader(String name, String value) {
List<String> list = clientHttpHeaders.get(name);
if (list == null) {
list = new ArrayList<>();
clientHttpHeaders.put(name, list);
}
list.add(value);
return request;
}
@Mock
public void end(Buffer chunk) {
clientBodyBuffer = chunk;
}
}.getMockInstance();
clientRequest = new RestClientRequestImpl(request);
}
Aggregations