INT-913, Modified logic in createPayloadFromTextContent(..) to get Payload from the Request body

This commit is contained in:
Oleg Zhurakousky
2009-12-09 18:11:25 +00:00
parent 97f9b8e618
commit 980cd41975

View File

@@ -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;
* </ul>
*
* @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) {