def httpdo(url, method='<STR_LIT:GET>', data=None):
start = time.time()<EOL>if isinstance(data, dict):<EOL><INDENT>data = json.dumps(data)<EOL><DEDENT>if DEBUG:<EOL><INDENT>print("<STR_LIT>".format(method=method.upper(), data=data or '<STR_LIT>', url=url))<EOL><DEDENT>try:<EOL><INDENT>response = requests.request(method, url, data=data, timeout=HTTP_TIMEOUT)<EOL><DEDENT>except (requests.exceptions.ConnectionError, requests.exceptions.ReadTimeout):<EOL><INDENT>time.sleep(<NUM_LIT:1.0>)<EOL>response = requests.request(method, url, data=data, timeout=HTTP_TIMEOUT)<EOL><DEDENT>if DEBUG:<EOL><INDENT>ms = (time.time() - start) * <NUM_LIT:1000><EOL>print('<STR_LIT>'.format(ms, response.text))<EOL><DEDENT>try:<EOL><INDENT>retjson = response.json()<EOL><DEDENT>except ValueError as e:<EOL><INDENT>raise ValueError(e, response.text)<EOL><DEDENT>r = convert(retjson)<EOL>if r.status != <NUM_LIT:0>:<EOL><INDENT>raise WDAError(r.status, r.value)<EOL><DEDENT>return r<EOL>
Do HTTP Request