refactoring, fix bugs, improve design, etc
fix bug: commit the body to out buffer, otherwise body will not be written to socket