def get_response(sock, buffer_size=<NUM_LIT>):
response = "<STR_LIT>"<EOL>extra = "<STR_LIT>"<EOL>while True:<EOL><INDENT>try:<EOL><INDENT>chunk = sock.recv(buffer_size)<EOL>if chunk:<EOL><INDENT>response += chunk<EOL><DEDENT><DEDENT>except socket.error as e:<EOL><INDENT>if e.errno not in [errno.EAGAIN, errno.EINTR]:<EOL><INDENT>raise<EOL><DEDENT><DEDENT>if not response:<EOL><INDENT>break<EOL><DEDENT>if "<STR_LIT:\n>" in response:<EOL><INDENT>response, extra = response.split("<STR_LIT:\n>", <NUM_LIT:1>)<EOL>break<EOL><DEDENT><DEDENT>return response, extra<EOL>
Helper method for retrieving a response from a given socket.

Returns two values in a tuple, the first is the reponse line and the second
is any extra data after the newline.