本文整理汇总了Java中org.springframework.http.client.ClientHttpResponse.getHeaders方法的典型用法代码示例。如果您正苦于以下问题:Java ClientHttpResponse.getHeaders方法的具体用法?Java ClientHttpResponse.getHeaders怎么用?Java ClientHttpResponse.getHeaders使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.http.client.ClientHttpResponse
的用法示例。
在下文中一共展示了ClientHttpResponse.getHeaders方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAuthorizationResponseExtractor
import org.springframework.http.client.ClientHttpResponse; //导入方法依赖的package包/类
protected ResponseExtractor<ResponseEntity<Void>> getAuthorizationResponseExtractor() {
return new ResponseExtractor<ResponseEntity<Void>>() {
public ResponseEntity<Void> extractData(ClientHttpResponse response) throws IOException {
return new ResponseEntity(response.getHeaders(), response.getStatusCode());
}
};
}
开发者ID:luotuo,项目名称:springboot-security-wechat,代码行数:8,代码来源:MyAuthorizationCodeAccessTokenProvider.java
示例2: getCharset
import org.springframework.http.client.ClientHttpResponse; //导入方法依赖的package包/类
/**
* @param response
* @return le charset du header
*/
private static Charset getCharset(ClientHttpResponse response) {
HttpHeaders headers = response.getHeaders();
MediaType contentType = headers.getContentType();
Charset charset = contentType != null ? contentType.getCharset() : null;
if (charset == null){
charset = Charset.forName(ConstanteUtils.WS_APOGEE_DEFAULT_CHARSET);
}
return charset;
}
示例3: getOrCreateWorkflowAndAddInteraction
import org.springframework.http.client.ClientHttpResponse; //导入方法依赖的package包/类
private void getOrCreateWorkflowAndAddInteraction(Pact pact, ClientHttpRequest clientRequest, ClientHttpResponse response) throws IOException {
String bodyString = StreamUtils.copyToString(response.getBody(), Charset.defaultCharset());
response.getBody().reset();
Pact.Interaction interaction = new Pact.Interaction(
null,
new Pact.InteractionRequest(restRequestDescriptor.getMethod(), urlencode(restRequestDescriptor.getUrl()), clientRequest.getHeaders(), extractBodyContent(restRequestDescriptor.getRequest())),
new Pact.InteractionResponse(response.getRawStatusCode(), response.getHeaders(), bodyString, schema),
objectConverter);
Pact.Workflow workflow = pact.getWorkflow(this.workflowId, this.providerStates);
workflow.addInteraction(interaction);
}
示例4: extractData
import org.springframework.http.client.ClientHttpResponse; //导入方法依赖的package包/类
@Override
public ResponseEntity<T> extractData(ClientHttpResponse response) throws IOException {
if (this.delegate != null) {
T body = this.delegate.extractData(response);
return new ResponseEntity<T>(body, response.getHeaders(), response.getStatusCode());
}
else {
return new ResponseEntity<T>(response.getHeaders(), response.getStatusCode());
}
}
示例5: getHttpStatusCode
import org.springframework.http.client.ClientHttpResponse; //导入方法依赖的package包/类
private HttpStatus getHttpStatusCode(ClientHttpResponse response) throws IOException {
HttpStatus statusCode;
try {
statusCode = response.getStatusCode();
}
catch (IllegalArgumentException ex) {
throw new UnknownHttpStatusCodeException(response.getRawStatusCode(),
response.getStatusText(), response.getHeaders(), getResponseBody(response), getCharset(response));
}
return statusCode;
}
示例6: handleError
import org.springframework.http.client.ClientHttpResponse; //导入方法依赖的package包/类
/**
* This default implementation throws a {@link HttpClientErrorException} if the response status code
* is {@link org.springframework.http.HttpStatus.Series#CLIENT_ERROR}, a {@link HttpServerErrorException}
* if it is {@link org.springframework.http.HttpStatus.Series#SERVER_ERROR},
* and a {@link RestClientException} in other cases.
*/
@Override
public void handleError(ClientHttpResponse response) throws IOException {
HttpStatus statusCode = getHttpStatusCode(response);
switch (statusCode.series()) {
case CLIENT_ERROR:
throw new HttpClientErrorException(statusCode, response.getStatusText(),
response.getHeaders(), getResponseBody(response), getCharset(response));
case SERVER_ERROR:
throw new HttpServerErrorException(statusCode, response.getStatusText(),
response.getHeaders(), getResponseBody(response), getCharset(response));
default:
throw new RestClientException("Unknown status code [" + statusCode + "]");
}
}
示例7: handleError
import org.springframework.http.client.ClientHttpResponse; //导入方法依赖的package包/类
@Override
public void handleError(ClientHttpResponse response) throws IOException {
HttpStatus statusCode = getHttpStatusCode(response);
// handle 3xx
switch (statusCode.series()) {
case REDIRECTION:
throw new HttpRedirectErrorException(statusCode, response.getStatusText(),
response.getHeaders(), getResponseBody(response), getCharset(response));
}
// handler 4xx and 5xx
super.handleError(response);
}
示例8: getHttpStatusCode
import org.springframework.http.client.ClientHttpResponse; //导入方法依赖的package包/类
protected HttpStatus getHttpStatusCode(ClientHttpResponse response) throws IOException {
try {
return response.getStatusCode();
} catch (IllegalArgumentException ex) {
throw new UnknownHttpStatusCodeException(response.getRawStatusCode(), response.getStatusText(),
response.getHeaders(), getResponseBody(response), getCharset(response));
}
}
示例9: doExecute
import org.springframework.http.client.ClientHttpResponse; //导入方法依赖的package包/类
@Override
protected <T> T doExecute(URI url, HttpMethod method, RequestCallback requestCallback, final ResponseExtractor<T>
responseExtractor) throws RestClientException {
final String[] status = new String[1];
final HttpStatus[] httpStatus = new HttpStatus[1];
final Object[] headers = new Object[1];
final String[] message = new String[1];
T results = null;
RestClientException exception = null;
try {
results = super.doExecute(url, method, requestCallback,
new ResponseExtractor<T>() {
@SuppressWarnings("rawtypes")
public T extractData(ClientHttpResponse response) throws IOException {
httpStatus[0] = response.getStatusCode();
headers[0] = response.getHeaders();
T data = null;
if (responseExtractor != null && (data = responseExtractor.extractData(response)) != null) {
if (data instanceof String) {
message[0] = ((String) data).length() + " bytes";
} else if (data instanceof Map) {
message[0] = ((Map) data).keySet().toString();
} else {
message[0] = data.getClass().getName();
}
return data;
} else {
message[0] = "<no data>";
return null;
}
}
});
status[0] = "OK";
} catch (RestClientException e) {
status[0] = "ERROR";
message[0] = e.getMessage();
exception = e;
if (e instanceof HttpStatusCodeException) {
httpStatus[0] = ((HttpStatusCodeException) e).getStatusCode();
}
}
addLogMessage(method, url, status[0], httpStatus[0], message[0]);
if (exception != null) {
throw exception;
}
return results;
}
示例10: getCharset
import org.springframework.http.client.ClientHttpResponse; //导入方法依赖的package包/类
private Charset getCharset(ClientHttpResponse response) {
HttpHeaders headers = response.getHeaders();
MediaType contentType = headers.getContentType();
return contentType != null ? contentType.getCharSet() : null;
}
示例11: getCharset
import org.springframework.http.client.ClientHttpResponse; //导入方法依赖的package包/类
protected Charset getCharset(ClientHttpResponse response) {
HttpHeaders headers = response.getHeaders();
MediaType contentType = headers.getContentType();
return (contentType != null ? contentType.getCharset() : null);
}