本文整理汇总了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;
}