OK it is different, but also there is only one read_from_client call!!! If read_from_client function doesn't read whole input, then problem is not solved too...
The error would only be there if $content_length is wrong.
So far, you haven't shown code that reproduces the problem. Please show code that reproduces the problem - all other diagnosis will remain vague guesswork.