foxykeep/DataDroid — pull request #26 by Maragues (2013-03-22 11:22:02+00:00)
Title: Fixes nginx returning "HTTP 411 Length Required" when sending a PUT request

Nginx servers return "411 Length Required" under 3 circumstances

*client sent invalid "Content-Length" header
client sent ... method without "Content-Length" header
client sent "Transfer-Encoding: chunked" header*

(Post by Igor Sysoev, nginx author http://www.ruby-forum.com/topic/162976#715758. Several other sources by googling)

Currently NetworkConnectionImpl.java creates PUT requests as GET or DELETE requests, that is, it appends all the parameters to the url and omits the Content-Length header.

This pull request constructs PUT requests as a POST, placing the parameters in the body. Also, I've added the Content-Length header to both PUT and POST requests.

If for any reason you prefer to keep PUT parameters in the url, this is a simpler fix

```java
if(method == Method.PUT)
headerMap.put(HTTP.CONTENT_LEN, String.valueOf(0));
```

So you may consider to ignore this pull request and add that snippet somewhere inside *execute*