当前位置: 首页>>代码示例>>Java>>正文


Java HttpInputMessage.getHeaders方法代码示例

本文整理汇总了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());
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:9,代码来源:HandlerMethodInvoker.java

示例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);
    }
}
 
开发者ID:FastBootWeixin,项目名称:FastBootWeixin,代码行数:34,代码来源:WxMediaResource.java

示例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]);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:13,代码来源:JsonViewRequestBodyAdvice.java


注:本文中的org.springframework.http.HttpInputMessage.getHeaders方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。