geosolutions-it / http-proxy

Lean and Mean HTTP Proxy written in Java
GNU General Public License v3.0
21 stars 31 forks source link

Post data set to null #16

Closed mstn closed 12 years ago

mstn commented 12 years ago

How to replicate the bug

curl -XPOST -H 'Content-type: application/xml' -d 'prova' http://localhost:8080/http_proxy/proxy?url=http://www.google.it

The http post request made by the HttpProxy does not contain post data.

mstn commented 12 years ago

The problem is a deprecated method in ProxyHttp.java

    private void handleStandard(EntityEnclosingMethod methodProxyRequest,
            HttpServletRequest httpServletRequest) throws IOException {
        try {
            // this method is deprecated! 
           methodProxyRequest.setRequestBody(httpServletRequest.getInputStream());
        } catch (IOException e) {
            throw new IOException(e);
        }
    }

The correct use is

methodProxyRequest.setRequestEntity(new InputStreamRequestEntity(httpServletRequest.getInputStream()));