working version with content-length checker