本文整理匯總了Java中org.springframework.http.HttpHeaders.containsKey方法的典型用法代碼示例。如果您正苦於以下問題:Java HttpHeaders.containsKey方法的具體用法?Java HttpHeaders.containsKey怎麽用?Java HttpHeaders.containsKey使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.springframework.http.HttpHeaders
的用法示例。
在下文中一共展示了HttpHeaders.containsKey方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: prepareHeaders
import org.springframework.http.HttpHeaders; //導入方法依賴的package包/類
private void prepareHeaders(Object body, HttpHeaders headers, String token) {
if( body!=null && !headers.containsKey(HttpHeaders.CONTENT_TYPE) ) {
headers.set(HttpHeaders.CONTENT_TYPE, "application/json");
}
if (token != null) {
headers.set(HttpHeaders.AUTHORIZATION, "Bearer " + token);
}
headers.set("X-Forwarded-User", "someone_important");
headers.set("X-Forwarded-Access-Token", token);
}
示例2: createRequest
import org.springframework.http.HttpHeaders; //導入方法依賴的package包/類
@Override
public ClientHttpRequest createRequest(URI uri, HttpMethod httpMethod) throws IOException {
ClientHttpRequest request = requestFactory.createRequest(uri, httpMethod);
HttpHeaders requestHeaders = request.getHeaders();
if (!requestHeaders.containsKey(HttpHeaders.AUTHORIZATION)) {
requestHeaders.add(HttpHeaders.AUTHORIZATION, "Bearer " + computeAuthorizationToken());
}
return request;
}
示例3: getHeaders
import org.springframework.http.HttpHeaders; //導入方法依賴的package包/類
/**
* 你問我為什麽要偷梁換柱?當然是因為微信接口返回的是JSON,但是Content-Type卻是Text_Pain啦,是否要考慮判斷內容?
* 暫時不需要,除非有些接口返回XML,也是這個頭,那就坑爹了
*
* @return dummy
*/
@Override
public HttpHeaders getHeaders() {
HttpHeaders headers = this.delegate.getHeaders();
if (headers.containsKey(HttpHeaders.CONTENT_DISPOSITION)) {
return headers;
}
if (headers.containsKey(HttpHeaders.CONTENT_TYPE) && headers.getContentType().equals(MediaType.TEXT_PLAIN)) {
headers.setContentType(MediaType.APPLICATION_JSON);
}
if (!headers.containsKey(WxWebUtils.X_WX_REQUEST_URL)) {
headers.add(WxWebUtils.X_WX_REQUEST_URL, request.getURI().toString());
}
return headers;
}