本文整理了Java中feign.Response.request
方法的一些代码示例,展示了Response.request
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Response.request
方法的具体详情如下:
包路径:feign.Response
类名称:Response
方法名:request
暂无
代码示例来源:origin: liuyangming/ByteTCC
public Object decode(Response resp, Type type) throws IOException, DecodeException, FeignException {
Request request = resp.request();
String reqTransactionStr = this.getHeaderValue(request, HEADER_TRANCACTION_KEY);
String reqPropagationStr = this.getHeaderValue(request, HEADER_PROPAGATION_KEY);
String respTransactionStr = this.getHeaderValue(resp, HEADER_TRANCACTION_KEY);
String respPropagationStr = this.getHeaderValue(resp, HEADER_PROPAGATION_KEY);
if (StringUtils.isBlank(reqTransactionStr)) {
return this.delegate.decode(resp, type);
} else if (StringUtils.isBlank(reqPropagationStr)) {
return this.delegate.decode(resp, type);
}
try {
String transactionStr = StringUtils.isBlank(respTransactionStr) ? reqTransactionStr : respTransactionStr;
String propagationStr = StringUtils.isBlank(respPropagationStr) ? reqPropagationStr : respPropagationStr;
byte[] byteArray = Base64.getDecoder().decode(transactionStr); // ByteUtils.stringToByteArray(transactionStr);
TransactionContext transactionContext = (TransactionContext) SerializeUtils.deserializeObject(byteArray);
SpringCloudBeanRegistry beanRegistry = SpringCloudBeanRegistry.getInstance();
RemoteCoordinator remoteCoordinator = beanRegistry.getConsumeCoordinator(propagationStr);
TransactionResponseImpl response = new TransactionResponseImpl();
response.setTransactionContext(transactionContext);
response.setSourceTransactionCoordinator(remoteCoordinator);
} catch (IOException ex) {
logger.error("Error occurred while decoding response({})!", resp, ex);
}
return this.delegate.decode(resp, type);
}
代码示例来源:origin: liuyangming/ByteTCC
public Exception decode(String methodKey, Response resp) {
Request request = resp.request();
String reqTransactionStr = this.getHeaderValue(request, HEADER_TRANCACTION_KEY);
String reqPropagationStr = this.getHeaderValue(request, HEADER_PROPAGATION_KEY);
String respTransactionStr = this.getHeaderValue(resp, HEADER_TRANCACTION_KEY);
String respPropagationStr = this.getHeaderValue(resp, HEADER_PROPAGATION_KEY);
if (StringUtils.isBlank(reqTransactionStr)) {
return this.delegate.decode(methodKey, resp);
} else if (StringUtils.isBlank(reqPropagationStr)) {
return this.delegate.decode(methodKey, resp);
}
// int status = resp.status();
try {
String transactionStr = StringUtils.isBlank(respTransactionStr) ? reqTransactionStr : respTransactionStr;
String propagationStr = StringUtils.isBlank(respPropagationStr) ? reqPropagationStr : respPropagationStr;
byte[] byteArray = Base64.getDecoder().decode(transactionStr); // ByteUtils.stringToByteArray(transactionStr);
TransactionContext transactionContext = (TransactionContext) SerializeUtils.deserializeObject(byteArray);
SpringCloudBeanRegistry beanRegistry = SpringCloudBeanRegistry.getInstance();
RemoteCoordinator remoteCoordinator = beanRegistry.getConsumeCoordinator(propagationStr);
TransactionResponseImpl response = new TransactionResponseImpl();
response.setTransactionContext(transactionContext);
response.setSourceTransactionCoordinator(remoteCoordinator);
} catch (IOException ex) {
logger.error("Error occurred while decoding response: methodKey= {}, response= {}", methodKey, resp, ex);
}
return this.delegate.decode(methodKey, resp);
}
代码示例来源:origin: de.digitalcollections.cudami/dc-cudami-client-openfeign
public HttpException(String methodKey, Response response) {
super(String.format("Got %d for backend call %s.%n⤷ %s",
response.status(), methodKey, response.request()));
if (response.body() != null) {
try {
try (InputStreamReader ir = new InputStreamReader(response.body().asInputStream())) {
errorMessage = new BufferedReader(ir).lines().parallel().collect(Collectors.joining(" "));
errorMessage = errorMessage.replaceFirst("^\"", "").replaceFirst("\"$", "");
}
} catch (IOException e) {
errorMessage = "Cannot read error message because of " + e.getMessage();
}
}
this.statuscode = response.status();
}
代码示例来源:origin: liuyangming/ByteJTA
public Object decode(Response resp, Type type) throws IOException, DecodeException, FeignException {
Request request = resp.request();
String reqTransactionStr = this.getHeaderValue(request, HEADER_TRANCACTION_KEY);
String reqPropagationStr = this.getHeaderValue(request, HEADER_PROPAGATION_KEY);
String respTransactionStr = this.getHeaderValue(resp, HEADER_TRANCACTION_KEY);
String respPropagationStr = this.getHeaderValue(resp, HEADER_PROPAGATION_KEY);
if (StringUtils.isBlank(reqTransactionStr)) {
return this.delegate.decode(resp, type);
} else if (StringUtils.isBlank(reqPropagationStr)) {
return this.delegate.decode(resp, type);
}
try {
String transactionStr = StringUtils.isBlank(respTransactionStr) ? reqTransactionStr : respTransactionStr;
String propagationStr = StringUtils.isBlank(respPropagationStr) ? reqPropagationStr : respPropagationStr;
byte[] byteArray = Base64.getDecoder().decode(transactionStr); // ByteUtils.stringToByteArray(transactionStr);
TransactionContext transactionContext = (TransactionContext) SerializeUtils.deserializeObject(byteArray);
SpringCloudBeanRegistry beanRegistry = SpringCloudBeanRegistry.getInstance();
RemoteCoordinator remoteCoordinator = beanRegistry.getConsumeCoordinator(propagationStr);
TransactionResponseImpl response = new TransactionResponseImpl();
response.setTransactionContext(transactionContext);
response.setSourceTransactionCoordinator(remoteCoordinator);
} catch (IOException ex) {
logger.error("Error occurred while decoding response({})!", resp, ex);
}
return this.delegate.decode(resp, type);
}
代码示例来源:origin: liuyangming/ByteJTA
public Exception decode(String methodKey, Response resp) {
Request request = resp.request();
String reqTransactionStr = this.getHeaderValue(request, HEADER_TRANCACTION_KEY);
String reqPropagationStr = this.getHeaderValue(request, HEADER_PROPAGATION_KEY);
String respTransactionStr = this.getHeaderValue(resp, HEADER_TRANCACTION_KEY);
String respPropagationStr = this.getHeaderValue(resp, HEADER_PROPAGATION_KEY);
if (StringUtils.isBlank(reqTransactionStr)) {
return this.delegate.decode(methodKey, resp);
} else if (StringUtils.isBlank(reqPropagationStr)) {
return this.delegate.decode(methodKey, resp);
}
// int status = resp.status();
try {
String transactionStr = StringUtils.isBlank(respTransactionStr) ? reqTransactionStr : respTransactionStr;
String propagationStr = StringUtils.isBlank(respPropagationStr) ? reqPropagationStr : respPropagationStr;
byte[] byteArray = Base64.getDecoder().decode(transactionStr); // ByteUtils.stringToByteArray(transactionStr);
TransactionContext transactionContext = (TransactionContext) SerializeUtils.deserializeObject(byteArray);
SpringCloudBeanRegistry beanRegistry = SpringCloudBeanRegistry.getInstance();
RemoteCoordinator remoteCoordinator = beanRegistry.getConsumeCoordinator(propagationStr);
TransactionResponseImpl response = new TransactionResponseImpl();
response.setTransactionContext(transactionContext);
response.setSourceTransactionCoordinator(remoteCoordinator);
} catch (IOException ex) {
logger.error("Error occurred while decoding response: methodKey= {}, response= {}", methodKey, resp, ex);
}
return this.delegate.decode(methodKey, resp);
}
代码示例来源:origin: twitch4j/twitch4j
.addContextValue("requestUrl", response.request().url())
.addContextValue("requestMethod", response.request().httpMethod())
.addContextValue("requestHeaders", response.request().headers().entrySet().toString())
.addContextValue("responseBody", responseBody);
} else if (response.status() == 404) {
throw new NotFoundException()
.addContextValue("requestUrl", response.request().url())
.addContextValue("requestMethod", response.request().httpMethod())
.addContextValue("requestHeaders", response.request().headers().entrySet().toString())
.addContextValue("responseBody", responseBody);
} else if (response.status() == 503) {
.addContextValue("requestUrl", response.request().url())
.addContextValue("requestMethod", response.request().httpMethod())
.addContextValue("requestHeaders", response.request().headers().entrySet().toString())
.addContextValue("responseBody", responseBody)
.addContextValue("errorType", helixError.getError())
代码示例来源:origin: twitch4j/twitch4j
.addContextValue("requestUrl", response.request().url())
.addContextValue("requestMethod", response.request().httpMethod())
.addContextValue("requestHeaders", response.request().headers().entrySet().toString())
.addContextValue("responseBody", responseBody);
} else if (response.status() == 404) {
throw new NotFoundException()
.addContextValue("requestUrl", response.request().url())
.addContextValue("requestMethod", response.request().httpMethod())
.addContextValue("requestHeaders", response.request().headers().entrySet().toString())
.addContextValue("responseBody", responseBody);
} else if (response.status() == 503) {
.addContextValue("requestUrl", response.request().url())
.addContextValue("requestMethod", response.request().httpMethod())
.addContextValue("requestHeaders", response.request().headers().entrySet().toString())
.addContextValue("responseBody", responseBody)
.addContextValue("errorType", error.getError())
代码示例来源:origin: twitch4j/twitch4j
.addContextValue("requestUrl", response.request().url())
.addContextValue("requestMethod", response.request().httpMethod())
.addContextValue("requestHeaders", response.request().headers().entrySet().toString())
.addContextValue("responseBody", responseBody);
} else if (response.status() == 404) {
throw new NotFoundException()
.addContextValue("requestUrl", response.request().url())
.addContextValue("requestMethod", response.request().httpMethod())
.addContextValue("requestHeaders", response.request().headers().entrySet().toString())
.addContextValue("responseBody", responseBody);
} else if (response.status() == 503) {
.addContextValue("requestUrl", response.request().url())
.addContextValue("requestMethod", response.request().httpMethod())
.addContextValue("requestHeaders", response.request().headers().entrySet().toString())
.addContextValue("responseBody", responseBody)
.addContextValue("errorType", error.getError())
代码示例来源:origin: spring-cloud/spring-cloud-openfeign
public RibbonResponseStatusCodeException(String serviceId, Response response, byte[] body, URI uri) {
super(serviceId, response.status(), response, uri);
this.response = Response.builder().body(new ByteArrayInputStream(body), body.length)
.headers(response.headers()).reason(response.reason())
.status(response.status()).request(response.request()).build();
}
代码示例来源:origin: org.springframework.cloud/spring-cloud-openfeign-core
public RibbonResponseStatusCodeException(String serviceId, Response response, byte[] body, URI uri) {
super(serviceId, response.status(), response, uri);
this.response = Response.builder().body(new ByteArrayInputStream(body), body.length)
.headers(response.headers()).reason(response.reason())
.status(response.status()).request(response.request()).build();
}
内容来源于网络,如有侵权,请联系作者删除!