Factor out the code that reads the response from server.

It will serve as a start point for parsing the response.

Signed-off-by: Thiago Farina <tfarina@chromium.org>