'This method was previously used in the framework to perform a HEAD
request before each GET/POST (ouch!) and get the size of the response.
The bad thing was that I was performing two requests for each
resource... I moved the "protection against big files" to the
keepalive.py module.
I left it here because maybe I want to use it at some point. Mainly
to call it directly.
:return: The file size of the remote file.'

def get_remote_file_size(self, req, cache=True):

    res = self.HEAD(req.get_full_url(), headers=req.headers, data=req.get_data(), cache=cache)
    resource_length = None
    for i in res.get_headers():
        if (i.lower() == 'content-length'):
            resource_length = res.get_headers()[i]
            if resource_length.isdigit():
                resource_length = int(resource_length)
            else:
                msg = 'The    content    length    header    value    of    the    response    wasn\'t    an    integer,    this    is    strange...    The    value    is:    "%s".'
                om.out.error((msg % res.get_headers()[i]))
                raise HTTPRequestException(msg, request=req)
    if (resource_length is not None):
        return resource_length
    else:
        msg = ("The    response    didn't    contain    a    content-length    header.    Unable    to    return    the    remote    file    size    of    request    with    id:    %s" % res.id)
        om.out.debug(msg)
        return 0
