'Fetch a URL, optionally caching for a specified time.
Args:
url:
The URL to retrieve
post_data:
A dict of (str, unicode) key/value pairs.
If set, POST will be used.
parameters:
A dict whose key/value pairs should encoded and added
to the query string. [Optional]
no_cache:
If true, overrides the cache on the current request
use_gzip_compression:
If True, tells the server to gzip-compress the response.
It does not apply to POST requests.
Defaults to None, which will get the value to use from
the instance variable self._use_gzip [Optional]
Returns:
A string containing the body of the response.'

def _FetchUrl(self, url, post_data=None, parameters=None, no_cache=None, use_gzip_compression=None):

    extra_params = {}
    if self._default_params:
        extra_params.update(self._default_params)
    if parameters:
        extra_params.update(parameters)
    if post_data:
        http_method = 'POST'
    else:
        http_method = 'GET'
    if self._debugHTTP:
        _debug = 1
    else:
        _debug = 0
    http_handler = self._urllib.HTTPHandler(debuglevel=_debug)
    https_handler = self._urllib.HTTPSHandler(debuglevel=_debug)
    http_proxy = os.environ.get('http_proxy')
    https_proxy = os.environ.get('https_proxy')
    if ((http_proxy is None) or (https_proxy is None)):
        proxy_status = False
    else:
        proxy_status = True
    opener = self._urllib.OpenerDirector()
    opener.add_handler(http_handler)
    opener.add_handler(https_handler)
    if (proxy_status is True):
        proxy_handler = self._urllib.ProxyHandler({'http': str(http_proxy), 'https': str(https_proxy)})
        opener.add_handler(proxy_handler)
    if (use_gzip_compression is None):
        use_gzip = self._use_gzip
    else:
        use_gzip = use_gzip_compression
    if (use_gzip and (not post_data)):
        opener.addheaders.append(('Accept-Encoding', 'gzip'))
    if (self._oauth_consumer is not None):
        if (post_data and (http_method == 'POST')):
            parameters = post_data.copy()
        req = oauth.Request.from_consumer_and_token(self._oauth_consumer, token=self._oauth_token, http_method=http_method, http_url=url, parameters=parameters)
        req.sign_request(self._signature_method_hmac_sha1, self._oauth_consumer, self._oauth_token)
        headers = req.to_header()
        if (http_method == 'POST'):
            encoded_post_data = req.to_postdata()
        else:
            encoded_post_data = None
            url = req.to_url()
    else:
        url = self._BuildUrl(url, extra_params=extra_params)
        encoded_post_data = self._EncodePostData(post_data)
    if (encoded_post_data or no_cache or (not self._cache) or (not self._cache_timeout)):
        response = opener.open(url, encoded_post_data)
        url_data = self._DecompressGzippedResponse(response)
        opener.close()
    else:
        if self._consumer_key:
            key = ((self._consumer_key + ':') + url)
        else:
            key = url
        last_cached = self._cache.GetCachedTime(key)
        if ((not last_cached) or (time.time() >= (last_cached + self._cache_timeout))):
            try:
                response = opener.open(url, encoded_post_data)
                url_data = self._DecompressGzippedResponse(response)
                self._cache.Set(key, url_data)
            except urllib2.HTTPError as e:
                print e
            opener.close()
        else:
            url_data = self._cache.Get(key)
    return url_data
