def _CalculateRequestSize(self, req):
"""Calculates the request size.
Args:
req: A tuple of (uri, method name, request body, header map)
Returns:
the size of the request, in bytes.
"""
uri, method, body, headers = req
(unused_scheme,
unused_host_port, url_path,
unused_query, unused_fragment) = urlparse.urlsplit(uri)
size = len('%s %s HTTP/1.1\n' % (method, url_path))
size += self._CalculateHeaderSize(headers)
if body:
size += len(body)
return size
评论列表
文章目录