Extract the code for reading the response from server in a "generic" helper function.

That way we can reuse this code later.

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