refactor of response body stream to socket