From 980cd41975aeb290fa0a89aebcd6534b7a02eb97 Mon Sep 17 00:00:00 2001 From: Oleg Zhurakousky Date: Wed, 9 Dec 2009 18:11:25 +0000 Subject: [PATCH] INT-913, Modified logic in createPayloadFromTextContent(..) to get Payload from the Request body --- .../http/DefaultInboundRequestMapper.java | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/org.springframework.integration.http/src/main/java/org/springframework/integration/http/DefaultInboundRequestMapper.java b/org.springframework.integration.http/src/main/java/org/springframework/integration/http/DefaultInboundRequestMapper.java index 1469a5b467..b6fc6ac002 100644 --- a/org.springframework.integration.http/src/main/java/org/springframework/integration/http/DefaultInboundRequestMapper.java +++ b/org.springframework.integration.http/src/main/java/org/springframework/integration/http/DefaultInboundRequestMapper.java @@ -16,7 +16,6 @@ package org.springframework.integration.http; -import java.io.BufferedReader; import java.io.File; import java.io.IOException; import java.io.InputStream; @@ -34,9 +33,9 @@ import javax.servlet.http.HttpServletResponse; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; - import org.springframework.integration.core.Message; import org.springframework.integration.message.MessageBuilder; +import org.springframework.util.FileCopyUtils; import org.springframework.web.multipart.MultipartException; import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartHttpServletRequest; @@ -69,6 +68,7 @@ import org.springframework.web.multipart.MultipartResolver; * * * @author Mark Fisher + * @author Oleg Zhurakousky * @since 1.0.2 */ public class DefaultInboundRequestMapper implements InboundRequestMapper { @@ -236,17 +236,9 @@ public class DefaultInboundRequestMapper implements InboundRequestMapper { } private Object createPayloadFromTextContent(HttpServletRequest request) throws IOException { - StringBuilder sb = new StringBuilder(); - BufferedReader reader = request.getReader(); - int contentLength = request.getContentLength(); - int bufferLength = (contentLength > -1) ? contentLength : 1024; - char[] buffer = new char[bufferLength]; - int charsRead = 0; - while (reader.ready() && (charsRead = reader.read(buffer, 0, bufferLength)) != -1) { - sb.append(buffer, 0, charsRead); - buffer = new char[bufferLength]; - } - return sb.toString(); + String charSet = request.getCharacterEncoding() == null ? "utf-8" : request.getCharacterEncoding(); + String str = new String(FileCopyUtils.copyToByteArray(request.getInputStream()), charSet); + return str; } private Object createPayloadFromSerializedObject(HttpServletRequest request) {