Execute the given HTTP method and returns if it's success or not
        and the response as a string if not success and as python object after
        unjson if it's success.
171871
def http_method(self, method):
        
        self.build_url()

        try:
            response = self.get_http_method(method)
            is_success = response.ok

            try:
                response_message = response.json()
            except ValueError:
                response_message = response.text

        except requests.exceptions.RequestException as exc:
            is_success = False
            response_message = exc.args

        return is_success, response_message
1321277
def request(method, uri, *args, **kwargs):
    
    req_method = req_methods[method.upper()]
    raise_exception = kwargs.pop("raise_exception", True)
    raw_content = kwargs.pop("raw_content", False)
    kwargs["headers"] = kwargs.get("headers", {})
    http_log_req(method, uri, args, kwargs)
    data = None
    if "data" in kwargs:
        # The 'data' kwarg is used when you don't want json encoding.
        data = kwargs.pop("data")
    elif "body" in kwargs:
        if "Content-Type" not in kwargs["headers"]:
            kwargs["headers"]["Content-Type"] = "application/json"
        data = json.dumps(kwargs.pop("body"))
    if data:
        resp = req_method(uri, data=data, **kwargs)
    else:
        resp = req_method(uri, **kwargs)
    if raw_content:
        body = resp.content
    else:
        try:
            body = resp.json()
        except ValueError:
            # No JSON in response
            body = resp.content
    http_log_resp(resp, body)
    if resp.status_code >= 400 and raise_exception:
        raise exc.from_response(resp, body)
    return resp, body
846247
def run
      if response.is_a? @expected_response
        self.class.on_response.call(self, response)
        response.tap do
          parse_response!
        end
      else
        raise HTTPError.new(error_message, response: response)
      end
    end
553977
def success(headers = None, data = ''):
    
    passed_headers = {} if headers is None else headers
    if isinstance(data, dict): data = json.dumps(data)
    ret_headers = {'status' : 'ok'}
    ret_headers.update(passed_headers)
    return server_responce(ret_headers, data)
572932
def perform_api_request(
        self,
        url,
        method='POST',
        headers=None,
        body=None,
        **kwargs
    ):
        '''
        
        '''
        assert method in ('GET', 'POST')
        if method == 'GET':
            response = self._perform_get(url, headers=headers, **kwargs)
        elif method == 'POST':
            response = self._perform_post(url, headers=headers, data=body, **kwargs)
        return response
926898
protected <T> T _execute(
                    final String string_url,
                    final HttpMethod method,
                    final RequestCallback callback,
                    final ResponseExtractor<T> extractor
                    )
    {
        _LOG_.debug( "HTTP: method = " + method + ", URL=" + string_url );

        URI  uri = null;
        try {
            URL  url = new URL( string_url );   //throws MalformedURLException
            uri = url.toURI();                  //throws URISyntaxException
        } catch (Exception ex) {
            _LOG_.error( "HTTP client error: " + ex );
            throw new HttpException( ex );
        }

        T  response = null;
        try {
            RestTemplate  rest = new RestTemplate();
            response = rest.execute( uri, method, callback, extractor );
                            //throws RestClientException
        } catch (Exception ex) {
            _LOG_.error( "HTTP client error: " + ex );
            throw new HttpException( ex );
        }

        return response;
    }
1321809
def handle(self, endpoint, *args, **kwargs):
        
        method = self.request_method()

        try:
            if not method in self.http_methods.get(endpoint, {}):
                raise MethodNotImplemented(
                    "Unsupported method '{}' for {} endpoint.".format(
                        method,
                        endpoint
                    )
                )

            if not self.is_authenticated():
                raise Unauthorized()

            self.data = self.deserialize(method, endpoint, self.request_body())
            view_method = getattr(self, self.http_methods[endpoint][method])
            data = view_method(*args, **kwargs)
            if is_future(data):
                # need to check if the view_method is a generator or not
                data = yield data
            serialized = self.serialize(method, endpoint, data)
        except Exception as err:
            raise gen.Return(self.handle_error(err))

        status = self.status_map.get(self.http_methods[endpoint][method], OK)
        raise gen.Return(self.build_response(serialized, status=status))
1260909
def execute(method, path, parameters, headers = { accept: :json }, &block)
      payload = {}.merge(parameters)
      url = base_url + path

      request_arguments = {
        method:  method,
        url:     url,
        payload: payload,
        headers: headers
      }

      RestClient::Request.execute(request_arguments, &block)
    rescue RestClient::Unauthorized
      raise AuthError, "Authentication failed"
    rescue RestClient::InternalServerError
      raise ServerError, "Server error"
    rescue RestClient::Forbidden => e
      raise BadRequest, e.http_body
    end
1029555
def execute(self, url, params):
        
        response = requests.get(url, params=params, **self.config.requests_kwargs)

        if 520 <= response.status_code < 530:
            if self.config.handler52x:
                return self.config.handler52x(response, self, url, params)

        response.raise_for_status()

        if not self.config.response_type:
            return response.json()
        else:
            return response.text
1328497
async def _wrap_http(self, handler, *args, **kwargs):
        ''' '''
        try:
            method = self.request_method()
            # support preflight requests when CORS is enabled
            if method == 'OPTIONS':
                return self.build_http_response(None, status=NO_CONTENT)
            data = await handler(self, *args, **kwargs)
            # format the response object
            formatted = self.format(method, data)
            status = self.responses.get(method, OK)
            return self.build_http_response(formatted, status=status)
        except Exception as ex:
            return self.dispatch_error(ex)
693721
public void execute() throws HelloSignException {
        HttpURLConnection connection = getConnection();
        try {
            // Execute the request and save the HTTP status code
            lastHttpStatusCode = connection.getResponseCode();

            // Save the stream object for processing
            if (lastHttpStatusCode >= 200 && lastHttpStatusCode < 300) {
                logger.debug("OK!");
                lastResponseStream = connection.getInputStream();
            } else {
                logger.error("Error! HTTP Code = " + lastHttpStatusCode);
                lastResponseStream = connection.getErrorStream();
            }
        } catch (Exception ex) {
            throw new HelloSignException(ex);
        }
    }
1194964
private HttpResponse executeUnparsed(boolean usingHead) throws IOException {
    HttpResponse response;
    if (uploader == null) {
      // normal request (not upload)
      response = buildHttpRequest(usingHead).execute();
    } else {
      // upload request
      GenericUrl httpRequestUrl = buildHttpRequestUrl();
      HttpRequest httpRequest = getAbstractGoogleClient()
          .getRequestFactory().buildRequest(requestMethod, httpRequestUrl, httpContent);
      boolean throwExceptionOnExecuteError = httpRequest.getThrowExceptionOnExecuteError();

      response = uploader.setInitiationHeaders(requestHeaders)
          .setDisableGZipContent(disableGZipContent).upload(httpRequestUrl);
      response.getRequest().setParser(getAbstractGoogleClient().getObjectParser());
      // process any error
      if (throwExceptionOnExecuteError && !response.isSuccessStatusCode()) {
        throw newExceptionOnError(response);
      }
    }
    // process response
    lastResponseHeaders = response.getHeaders();
    lastStatusCode = response.getStatusCode();
    lastStatusMessage = response.getStatusMessage();
    return response;
  }
1286837
def executeTask(self,
                    inputs,
                    outSR=None,
                    processSR=None,
                    returnZ=False,
                    returnM=False,
                    f="json",
                    method="POST"
                    ):
        
        params = {
            "f" : f
        }
        url = self._url + "/execute"
        params = { "f" : "json" }
        if not outSR is None:
            params['env:outSR'] = outSR
        if not processSR is None:
            params['end:processSR'] = processSR
        params['returnZ'] = returnZ
        params['returnM'] = returnM
        for p in inputs:
            if isinstance(p, BaseGPObject):
                params[p.paramName] = p.value
            del p
        if method.lower() == "post":
            return self._post(url=url,
                                 param_dict=params,
                                 securityHandler=self._securityHandler,
                                 proxy_url=self._proxy_url,
                                 proxy_port=self._proxy_port)
        else:
            return self._get(url=url,
                                 param_dict=params,
                                 securityHandler=self._securityHandler,
                                 proxy_url=self._proxy_url,
                                 proxy_port=self._proxy_port)
228330
def _http_request(url,
                  method='GET',
                  headers=None,
                  data=None):
    '''
    
    '''
    req = requests.request(method,
                           url,
                           headers=headers,
                           data=data)
    ret = _default_ret()
    ok_status = METHOD_OK_STATUS.get(method, 200)
    if req.status_code != ok_status:
        ret.update({
            'comment': req.json().get('error', '')
        })
        return ret
    ret.update({
        'result': True,
        'out': req.json() if method != 'DELETE' else None  # no body when DELETE
    })
    return ret
1251018
public static HttpResponse execute(final String url, final String method) {
        return execute(url, method, null, null, new HashMap<>(), new HashMap<>());
    }
1215081
def http_call(self, url=None, **kwargs):
        
        if not url:
            url = self.search_url
        http_func, arg_name = self.get_http_method_arg_name()
        # Build the argument dictionary to pass in the http function
        _kwargs = {
            arg_name: kwargs,
        }
        # The actual HTTP call
        response = http_func(
            url=url.format(**kwargs),
            headers=self.get_http_headers(),
            **_kwargs
        )
        # Error handling
        if response.status_code != 200:
            logger.warning('Invalid Request for `%s`', response.url)
            # Raising a "requests" exception
            response.raise_for_status()
        return response.json()
238044
def _method_response_handler(self, response: Dict[str, Any]):
        
        code = response.get("CODE")
        if code in (200, 300):
            self._result_handler(response)
        else:
            asyncio.ensure_future(self._gen_result_handler(response))