https://issues.apache.org/bugzilla/show_bug.cgi?id=47410
Summary: HttpServletRequest.getInputStream is null with
Content-Type: application/x-www-form-urlencoded
Product: Tomcat 6
Version: unspecified
Platform: All
OS/Version: All
Status: NEW
Keywords: APIBug
Severity: critical
Priority: P2
Component: Servlet & JSP API
AssignedTo: [email protected]
ReportedBy: [email protected]
When client send xml message with Content-Type:
application/x-www-form-urlencoded. if you do "request.getParameter("message")"
first. then subsequent call request.getInportStream()return an empty
inputStream (not null, just not data).
Note:
1. If client set Content-Type: text/xml in request HTTP header, no problem.
2. If you do not do "request.getParameter("message")";
request.getInportStream() works. (can read the body data).
3. I understand the Content Type and client should not set
"x-www-form-urlencoded" if they just send XML message in HTTP body.
But, I still think it is bug. request.getInportStream() should be able to read
the data in HTTP body regardless what Content Type is.
Ed Xu
===============================================
POST /ecpr/a2a/MessageDispatcher HTTP/1.1
Content-Type: application/x-www-form-urlencoded
Host: ecprsit.wellsfargo.com:9001
Content-Length: 738
Expect: 100-continue
Connection: Close
<?xml version="1.0" encoding="utf-8"?>
<KODL009>
<Header version="1.0">
<RequestorId>seth.a.miller</RequestorId>
<AuthorizationId>seth.a.miller</AuthorizationId>
<ApplicationCode>5C</ApplicationCode>
<ChannelCode>INET</ChannelCode>
<DeviceId>DTC1D0090B7B0BD</DeviceId>
<AccountingUnit>74501</AccountingUnit>
<CorrelationId>bbf84e4a-e5ff-4fbc-be94-846b538a3dde</CorrelationId>
<CreationTimestamp>633810128982475233</CreationTimestamp>
<MessageType>RQST</MessageType>
<Timeout>30</Timeout>
</Header>
<Body>
<IndividualSearch>
<IndividualFirstName>w</IndividualFirstName>
<IndividualLastName>w</IndividualLastName>
</IndividualSearch>
</Body>
=====================================
public void doPost(
HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
String message = request.getParameter("message"); // Cause input stream
empty
if (message == null) {
// In case the client posted the data raw...
int BUFSIZE = 4096;
InputStream in = null;
ByteArrayOutputStream byteStream = null;
try {
in = request.getInputStream();
byteStream = new ByteArrayOutputStream(BUFSIZE);
byte[] buf = new byte[BUFSIZE];
int len;
long READ_TIME_LIMIT = 2000;
while ((len = in.read(buf, 0, BUFSIZE)) != -1) {
..................
// Problem:
// InputStream has nothing althoung the HTTP request contains body)
}
}
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]