'GETs a file from a given URL
Args:
url (str): The URL to GET
output_stream (file): File to write the response body to.
Returns:
A (int,dict,string,int) tuple of the file length, dict of the response
headers, absolute URI of the response and HTTP response code.'

@defer.inlineCallbacks
def get_file(self, url, output_stream, max_size=None):

    response = (yield self.request('GET', url.encode('ascii'), headers=Headers({'User-Agent': [self.user_agent]})))
    headers = dict(response.headers.getAllRawHeaders())
    if (('Content-Length' in headers) and (headers['Content-Length'] > max_size)):
        logger.warn(('Requested    URL    is    too    large    >    %r    bytes' % (self.max_size,)))
        raise SynapseError(502, ('Requested    file    is    too    large    >    %r    bytes' % (self.max_size,)), Codes.TOO_LARGE)
    if (response.code > 299):
        logger.warn(('Got    %d    when    downloading    %s' % (response.code, url)))
        raise SynapseError(502, ('Got    error    %d' % (response.code,)), Codes.UNKNOWN)
    try:
        length = (yield preserve_context_over_fn(_readBodyToFile, response, output_stream, max_size))
    except Exception as e:
        logger.exception('Failed    to    download    body')
        raise SynapseError(502, ('Failed    to    download    remote    body:    %s' % e), Codes.UNKNOWN)
    defer.returnValue((length, headers, response.request.absoluteURI, response.code))
