You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@sling.apache.org by Carl Hall <ca...@hallwaytech.com> on 2010/10/26 22:09:14 UTC
request.getInputStream() yields unreadable stream
I'm trying to read the raw body of a request so I can proxy it over to
another service but can't seem to read an input stream from the request.
This is the gist of my code:
protected void doPost(SlingHttpServletRequest request,
SlingHttpServletResponse response)
throws ServletException, IOException {
InputStream is = request.getInputStream();
int i = is.read(); // i == -1 , always
}
Should I use a different means to get an input stream for the request body?
Re: request.getInputStream() yields unreadable stream
Posted by Felix Meschberger <fm...@gmail.com>.
Hi,
Sling processes the raw request input for multipart/form-data requests
to be able to transparently provide posted form data. This is an
extension ot the Servlet API which explicitly states that the Servlet
Container does not parse multipart/form-data requests.
See [1] and [2] for full details and information on how to get at
uploaded binary data (file uploads).
Regards
Felix
[1] http://sling.apache.org/site/request-parameters.html
[2]
http://sling.apache.org/apidocs/sling5/index.html?org/apache/sling/api/request/RequestParameter.html
On 26.10.2010 22:09, Carl Hall wrote:
> I'm trying to read the raw body of a request so I can proxy it over to
> another service but can't seem to read an input stream from the request.
>
> This is the gist of my code:
>
> protected void doPost(SlingHttpServletRequest request,
> SlingHttpServletResponse response)
> throws ServletException, IOException {
> InputStream is = request.getInputStream();
> int i = is.read(); // i == -1 , always
> }
>
> Should I use a different means to get an input stream for the request body?
>