'Calculates the request size.
May be overriden to support different types of requests.
Args:
req: A urllib2.Request.
Returns:
the size of the request, in bytes.'

def _CalculateRequestSize(self, req):

    (unused_scheme, unused_host_port, url_path, unused_query, unused_fragment) = urlparse.urlsplit(req.get_full_url())
    size = len(('%s    %s    HTTP/1.1\n' % (req.get_method(), url_path)))
    size += self._CalculateHeaderSize(req.headers)
    size += self._CalculateHeaderSize(req.unredirected_hdrs)
    data = req.get_data()
    if data:
        size += len(data)
    return size
