本文整理匯總了Java中org.springframework.http.HttpInputMessage.getHeaders方法的典型用法代碼示例。如果您正苦於以下問題:Java HttpInputMessage.getHeaders方法的具體用法?Java HttpInputMessage.getHeaders怎麽用?Java HttpInputMessage.getHeaders使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.springframework.http.HttpInputMessage
的用法示例。
在下文中一共展示了HttpInputMessage.getHeaders方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: EmptyBodyCheckingHttpInputMessage
import org.springframework.http.HttpInputMessage; //導入方法依賴的package包/類
public EmptyBodyCheckingHttpInputMessage(HttpInputMessage inputMessage) throws IOException {
this.headers = inputMessage.getHeaders();
InputStream inputStream = inputMessage.getBody();
if (inputStream == null) {
this.body = null;
}
else if (inputStream.markSupported()) {
inputStream.mark(1);
this.body = (inputStream.read() != -1 ? inputStream : null);
inputStream.reset();
}
else {
PushbackInputStream pushbackInputStream = new PushbackInputStream(inputStream);
int b = pushbackInputStream.read();
if (b == -1) {
this.body = null;
}
else {
this.body = pushbackInputStream;
pushbackInputStream.unread(b);
}
}
this.method = ((HttpRequest) inputMessage).getMethod();
}
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:25,代碼來源:AbstractMessageConverterMethodArgumentResolver.java
示例2: resolveHttpEntityRequest
import org.springframework.http.HttpInputMessage; //導入方法依賴的package包/類
private HttpEntity<?> resolveHttpEntityRequest(MethodParameter methodParam, NativeWebRequest webRequest)
throws Exception {
HttpInputMessage inputMessage = createHttpInputMessage(webRequest);
Class<?> paramType = getHttpEntityType(methodParam);
Object body = readWithMessageConverters(methodParam, inputMessage, paramType);
return new HttpEntity<Object>(body, inputMessage.getHeaders());
}
示例3: WxMediaResource
import org.springframework.http.HttpInputMessage; //導入方法依賴的package包/類
/**
* 是否真的需要這麽多成員變量?
*
* @param httpInputMessage
* @throws IOException
*/
public WxMediaResource(HttpInputMessage httpInputMessage) throws IOException {
this.isFileResource = false;
if (httpInputMessage instanceof WxBufferingInputMessageWrapper) {
this.body = ((WxBufferingInputMessageWrapper) httpInputMessage).getRawBody();
} else {
this.body = StreamUtils.copyToByteArray(httpInputMessage.getBody());
}
this.httpHeaders = httpInputMessage.getHeaders();
this.contentType = httpHeaders.getContentType();
this.contentLength = httpHeaders.getContentLength();
// 判斷是否是json
if (!this.httpHeaders.containsKey(HttpHeaders.CONTENT_DISPOSITION)) {
this.isUrlMedia = true;
if (body[0] == '{') {
this.url = extractURL(body);
this.filename = extractFilenameFromURL(url);
} else if (httpHeaders.containsKey(WxWebUtils.X_WX_REQUEST_URL)) {
this.url = URI.create(httpHeaders.getFirst(WxWebUtils.X_WX_REQUEST_URL)).toURL();
this.filename = extractFilenameFromURL(url);
} else {
this.filename = UUID.randomUUID().toString() + ".jpg";
}
} else {
this.description = this.httpHeaders.getFirst(HttpHeaders.CONTENT_DISPOSITION);
this.filename = extractFilename(this.description);
}
}
示例4: beforeBodyRead
import org.springframework.http.HttpInputMessage; //導入方法依賴的package包/類
@Override
public HttpInputMessage beforeBodyRead(HttpInputMessage inputMessage, MethodParameter methodParameter,
Type targetType, Class<? extends HttpMessageConverter<?>> selectedConverterType) throws IOException {
JsonView annotation = methodParameter.getParameterAnnotation(JsonView.class);
Class<?>[] classes = annotation.value();
if (classes.length != 1) {
throw new IllegalArgumentException(
"@JsonView only supported for request body advice with exactly 1 class argument: " + methodParameter);
}
return new MappingJacksonInputMessage(inputMessage.getBody(), inputMessage.getHeaders(), classes[0]);
}