當前位置: 首頁>>代碼示例>>Java>>正文


Java ClientHttpResponse.getHeaders方法代碼示例

本文整理匯總了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;
}
 
開發者ID:EsupPortail,項目名稱:esup-ecandidat,代碼行數:14,代碼來源:SiScolRestUtils.java

示例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);
}
 
開發者ID:tyro,項目名稱:pact-spring-mvc,代碼行數:13,代碼來源:ReturnExpect.java

示例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());
	}
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:11,代碼來源:RestTemplate.java

示例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;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:12,代碼來源:DefaultResponseErrorHandler.java

示例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 + "]");
	}
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:21,代碼來源:DefaultResponseErrorHandler.java

示例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);
}
 
開發者ID:vianneyfaivre,項目名稱:Persephone,代碼行數:15,代碼來源:RestErrorHandler.java

示例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));
    }
}
 
開發者ID:FastBootWeixin,項目名稱:FastBootWeixin,代碼行數:9,代碼來源:WxResponseErrorHandler.java

示例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;
}
 
開發者ID:SAP,項目名稱:cf-java-client-sap,代碼行數:48,代碼來源:LoggingRestTemplate.java

示例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;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:6,代碼來源:DefaultResponseErrorHandler.java

示例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);
}
 
開發者ID:FastBootWeixin,項目名稱:FastBootWeixin,代碼行數:6,代碼來源:WxResponseErrorHandler.java


注:本文中的org.springframework.http.client.ClientHttpResponse.getHeaders方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。