Handle the chunked http requests.

The fix is based on Daniel Graña's commit which has not been merged into mainline.
It should fix issues 252 and 367.
Merge pull request #17 from pooya/shayan/chunked_http

Handle the chunked http requests.