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


Java HttpInputMessage.getBody方法代码示例

本文整理汇总了Java中org.springframework.http.HttpInputMessage.getBody方法的典型用法代码示例。如果您正苦于以下问题:Java HttpInputMessage.getBody方法的具体用法?Java HttpInputMessage.getBody怎么用?Java HttpInputMessage.getBody使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.http.HttpInputMessage的用法示例。


在下文中一共展示了HttpInputMessage.getBody方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: readInternal

import org.springframework.http.HttpInputMessage; //导入方法依赖的package包/类
@Override
protected ApplicationLogs readInternal(Class<? extends ApplicationLogs> clazz, HttpInputMessage inputMessage)
        throws IOException, HttpMessageNotReadableException {
    String boundary = getMessageBoundary(inputMessage);

    Multipart multipart = new Multipart(inputMessage.getBody(), boundary);

    ApplicationLogs logs = new ApplicationLogs();

    Multipart.Part part;
    while ((part = multipart.nextPart()) != null) {
        ApplicationLog log = messageParser.parseMessage(part.getContent());
        logs.add(log);
    }

    return logs;
}
 
开发者ID:SAP,项目名称:cf-java-client-sap,代码行数:18,代码来源:LoggregatorHttpMessageConverter.java

示例2: 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

示例3: readInternal

import org.springframework.http.HttpInputMessage; //导入方法依赖的package包/类
@Override
@SuppressWarnings("unchecked")
protected T readInternal(Class<? extends T> clazz, HttpInputMessage inputMessage)
		throws IOException, HttpMessageNotReadableException {

	WireFeedInput feedInput = new WireFeedInput();
	MediaType contentType = inputMessage.getHeaders().getContentType();
	Charset charset;
	if (contentType != null && contentType.getCharSet() != null) {
		charset = contentType.getCharSet();
	} else {
		charset = DEFAULT_CHARSET;
	}
	try {
		Reader reader = new InputStreamReader(inputMessage.getBody(), charset);
		return (T) feedInput.build(reader);
	}
	catch (FeedException ex) {
		throw new HttpMessageNotReadableException("Could not read WireFeed: " + ex.getMessage(), ex);
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:22,代码来源:AbstractWireFeedHttpMessageConverter.java

示例4: readInternal

import org.springframework.http.HttpInputMessage; //导入方法依赖的package包/类
@Override
@SuppressWarnings("unchecked")
protected T readInternal(Class<? extends T> clazz, HttpInputMessage inputMessage)
		throws IOException, HttpMessageNotReadableException {

	InputStream body = inputMessage.getBody();
	if (DOMSource.class.equals(clazz)) {
		return (T) readDOMSource(body);
	}
	else if (SAXSource.class.equals(clazz)) {
		return (T) readSAXSource(body);
	}
	else if (StAXSource.class.equals(clazz)) {
		return (T) readStAXSource(body);
	}
	else if (StreamSource.class.equals(clazz) || Source.class.equals(clazz)) {
		return (T) readStreamSource(body);
	}
	else {
		throw new HttpMessageConversionException("Could not read class [" + clazz +
				"]. Only DOMSource, SAXSource, StAXSource, and StreamSource are supported.");
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:24,代码来源:SourceHttpMessageConverter.java

示例5: readInternal

import org.springframework.http.HttpInputMessage; //导入方法依赖的package包/类
@Override
protected Object readInternal(Class<?> clazz, HttpInputMessage inputMessage) throws IOException, HttpMessageNotReadableException {

    MediaType contentType = inputMessage.getHeaders().getContentType();
    if (MEDIA_TYPE.isCompatibleWith(contentType)) {
        final Schema<?> schema = getSchema(clazz);
        final Object value = schema.newMessage();

        try (final InputStream stream = inputMessage.getBody()) {
            ProtobufIOUtil.mergeFrom(stream, value, (Schema<Object>) schema);
            return value;
        }
    }

    throw new HttpMessageNotReadableException(
            "Unrecognized HTTP media type " + inputMessage.getHeaders().getContentType().getType() + ".");
}
 
开发者ID:bobxwang,项目名称:springboot-scala-withswagger,代码行数:18,代码来源:ProtostuffHttpMessageConverter.java

示例6: read

import org.springframework.http.HttpInputMessage; //导入方法依赖的package包/类
@Override
public Object read(Type type, Class<?> contextClass, HttpInputMessage inputMessage) throws IOException, HttpMessageNotReadableException {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    InputStream in = inputMessage.getBody();
    byte[] buf = new byte[1024];
    for (; ; ) {
        int len = in.read(buf);
        if (len == -1) {
            break;
        }
        if (len > 0) {
            baos.write(buf, 0, len);
        }
    }
    byte[] bytes = baos.toByteArray();
    return readByBytes(type, bytes);
}
 
开发者ID:hs-web,项目名称:hsweb-framework,代码行数:18,代码来源:FastJsonGenericHttpMessageConverter.java

示例7: readInternal

import org.springframework.http.HttpInputMessage; //导入方法依赖的package包/类
@Override
protected Object readInternal(Class<?> clazz, HttpInputMessage inputMessage) throws IOException,
        HttpMessageNotReadableException {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    InputStream in = inputMessage.getBody();
    byte[] buf = new byte[1024];
    for (; ; ) {
        int len = in.read(buf);
        if (len == -1) {
            break;
        }
        if (len > 0) {
            baos.write(buf, 0, len);
        }
    }
    byte[] bytes = baos.toByteArray();
    return readByBytes(clazz, bytes);
}
 
开发者ID:hs-web,项目名称:hsweb-framework,代码行数:19,代码来源:FastJsonHttpMessageConverter.java

示例8: readInternal

import org.springframework.http.HttpInputMessage; //导入方法依赖的package包/类
@Override
@SuppressWarnings("unchecked")
protected T readInternal(Class<? extends T> clazz, HttpInputMessage inputMessage)
		throws IOException, HttpMessageNotReadableException {

	WireFeedInput feedInput = new WireFeedInput();
	MediaType contentType = inputMessage.getHeaders().getContentType();
	Charset charset =
			(contentType != null && contentType.getCharSet() != null? contentType.getCharSet() : DEFAULT_CHARSET);
	try {
		Reader reader = new InputStreamReader(inputMessage.getBody(), charset);
		return (T) feedInput.build(reader);
	}
	catch (FeedException ex) {
		throw new HttpMessageNotReadableException("Could not read WireFeed: " + ex.getMessage(), ex);
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:18,代码来源:AbstractWireFeedHttpMessageConverter.java

示例9: readInternal

import org.springframework.http.HttpInputMessage; //导入方法依赖的package包/类
@Override
@SuppressWarnings("unchecked")
protected T readInternal(Class<? extends T> clazz, HttpInputMessage inputMessage)
		throws IOException, HttpMessageNotReadableException {

	InputStream body = inputMessage.getBody();
	if (DOMSource.class == clazz) {
		return (T) readDOMSource(body);
	}
	else if (SAXSource.class == clazz) {
		return (T) readSAXSource(body);
	}
	else if (StAXSource.class == clazz) {
		return (T) readStAXSource(body);
	}
	else if (StreamSource.class == clazz || Source.class == clazz) {
		return (T) readStreamSource(body);
	}
	else {
		throw new HttpMessageConversionException("Could not read class [" + clazz +
				"]. Only DOMSource, SAXSource, StAXSource, and StreamSource are supported.");
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:24,代码来源:SourceHttpMessageConverter.java

示例10: readInternal

import org.springframework.http.HttpInputMessage; //导入方法依赖的package包/类
@Override
protected MultipartFile[] readInternal (Class<? extends MultipartFile[]> clazz, HttpInputMessage inputMessage
) throws IOException {
  val boundaryBytes = getMultiPartBoundary(inputMessage.getHeaders().getContentType());
  MultipartStream multipartStream = new MultipartStream(inputMessage.getBody(), boundaryBytes, bufSize, null);

  val multiparts = new LinkedList<ByteArrayMultipartFile>();
  for (boolean nextPart = multipartStream.skipPreamble(); nextPart; nextPart = multipartStream.readBoundary()) {
    ByteArrayMultipartFile multiPart;
    try {
      multiPart = readMultiPart(multipartStream);
    } catch (Exception e) {
      throw new HttpMessageNotReadableException("Multipart body could not be read.", e);
    }
    multiparts.add(multiPart);
  }
  return multiparts.toArray(new ByteArrayMultipartFile[multiparts.size()]);
}
 
开发者ID:OpenFeign,项目名称:feign-form,代码行数:19,代码来源:SpringManyMultipartFilesReader.java

示例11: readInternal

import org.springframework.http.HttpInputMessage; //导入方法依赖的package包/类
@Override
protected Object readInternal(Class<? extends Object> clazz, HttpInputMessage inputMessage) throws IOException,  HttpMessageNotReadableException {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    InputStream in = inputMessage.getBody();
    byte[] buf = new byte[1024];
    for (;;) {
        int len = in.read(buf);
        if (len == -1) {
            break;
        }
        if (len > 0) {
            baos.write(buf, 0, len);
        }
    }
    byte[] bytes = baos.toByteArray();
    return JSON.parseObject(bytes, 0, bytes.length, charset.newDecoder(), clazz);
}
 
开发者ID:summerDp,项目名称:dpCms,代码行数:18,代码来源:Fastjson2HttpMessageConverter.java

示例12: readTypeToken

import org.springframework.http.HttpInputMessage; //导入方法依赖的package包/类
private Object readTypeToken(final TypeToken<?> token, final HttpInputMessage inputMessage) throws IOException {
    final Reader reader = new InputStreamReader(inputMessage.getBody(), getCharset(inputMessage.getHeaders()));

    try {
        final String json = IOUtils.toString(reader);
        reader.close();

        // do the actual validation
        final ObjectMapper mapper = new ObjectMapper();
        mapper.enable(DeserializationFeature.FAIL_ON_READING_DUP_TREE_KEY);
        mapper.readTree(json);

        return this.gson.fromJson(json, token.getType());
    } catch (JsonParseException ex) {
        throw new HttpMessageNotReadableException("Could not read JSON: " + ex.getMessage(), ex);
    }
}
 
开发者ID:Ericsson,项目名称:eiffel-remrem-generate,代码行数:18,代码来源:GsonHttpMessageConverterWithValidate.java

示例13: readTypeToken

import org.springframework.http.HttpInputMessage; //导入方法依赖的package包/类
private Object readTypeToken(TypeToken<?> token, HttpInputMessage inputMessage) throws IOException {
  InputStreamReader json = new InputStreamReader(inputMessage.getBody(), this.getCharset(inputMessage.getHeaders()));
  try {
    return this.gson.fromJson(json, token.getType());
  } catch (JsonParseException var5) {
    throw new HttpMessageNotReadableException("JSON parse error: " + var5.getMessage(), var5);
  }
}
 
开发者ID:Huawei,项目名称:Server_Management_Common_eSightApi,代码行数:9,代码来源:GsonHttpMessageConverter.java

示例14: readObject

import org.springframework.http.HttpInputMessage; //导入方法依赖的package包/类
private Object readObject(HttpInputMessage inputMessage, TypeToken<?> token) throws IOException {
    try (Reader json = new InputStreamReader(inputMessage.getBody(), getCharset(inputMessage.getHeaders()))) {
        return this.gsonForReader.fromJson(json, token.getType());
    } catch (JsonParseException ex) {
        throw new HttpMessageNotReadableException("JSON parse error: " + ex.getMessage(), ex);
    }
}
 
开发者ID:FlowCI,项目名称:flow-platform,代码行数:8,代码来源:RawGsonMessageConverter.java

示例15: readInternal

import org.springframework.http.HttpInputMessage; //导入方法依赖的package包/类
protected Object readInternal(Class<? extends Object> clazz, HttpInputMessage inputMessage) throws IOException, HttpMessageNotReadableException {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    InputStream in = inputMessage.getBody();
    byte[] buf = new byte[1024];
    while (true) {
        int len = in.read(buf);
        if (len == -1) {
            byte[] bytes = baos.toByteArray();
            return JSON.parseObject(bytes, 0, bytes.length, this.charset.newDecoder(), (Type) clazz, new Feature[0]);
        } else if (len > 0) {
            baos.write(buf, 0, len);
        }
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:15,代码来源:FastJsonHttpMessageConverter.java


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