Don't retrieve the content length again from the headers. You have it already in `cont_len`. Also I would add the call to `strip()` to line 278.