

def _appengine_fetch(self, uri, params, method):
    if (method == 'GET'):
        uri = self._build_get_uri(uri, params)
    try:
        httpmethod = getattr(urlfetch, method)
    except AttributeError:
        raise NotImplementedError(("Google App Engine does not support method '%s'" % method))
    authstring = base64.encodestring(('%s:%s' % (self.auth_id, self.auth_token)))
    authstring = authstring.replace('\n', '')
    r = urlfetch.fetch(url=uri, payload=urllib.urlencode(params), method=httpmethod, headers={
        'Content-Type': 'application/x-www-form-urlencoded',
        'Authorization': ('Basic %s' % authstring),
    })
    if (r.status_code >= 300):
        raise HTTPErrorAppEngine(('HTTP %s: %s' % (r.status_code, r.content)))
    return r.content

dataset/ETHPy150Open plivo/plivohelper-python/plivohelper.py REST._appengine_fetch/original