Sends the request
17307
def request(self, server=None):
        
        request = {
            "headers": {"Content-Type": "application/json"},
            "timeout": self._pump.timeout,
            "data": self.context,
        }

        url = "{proto}://{server}/{endpoint}".format(
            proto=self._pump.protocol,
            server=server or self.server,
            endpoint=self.ENDPOINT,
        )

        response = self._pump._requester(requests.post, url, **request)

        try:
            server_data = response.json()
        except ValueError:
            raise ClientException(response.content)

        if "error" in server_data:
            raise ClientException(server_data["error"], self.context)

        _log.debug("Client registration recieved: %(id)s %(secret)s %(expire)s", {
            "id": server_data["client_id"],
            "secret": server_data["client_secret"],
            "expire": server_data["expires_at"],
        })

        return server_data
25808
private void sendRequest() {

        final String queryString = !eventSpinner.isEnabled() ? String.valueOf(queryEditText.getText()) : null;
        final String eventString = eventSpinner.isEnabled() ? String.valueOf(String.valueOf(eventSpinner.getSelectedItem())) : null;
        final String contextString = String.valueOf(contextEditText.getText());

        if (TextUtils.isEmpty(queryString) && TextUtils.isEmpty(eventString)) {
            onError(new AIError(getString(R.string.non_empty_query)));
            return;
        }

        final AsyncTask<String, Void, AIResponse> task = new AsyncTask<String, Void, AIResponse>() {

            private AIError aiError;

            @Override
            protected AIResponse doInBackground(final String... params) {
                final AIRequest request = new AIRequest();
                String query = params[0];
                String event = params[1];

                if (!TextUtils.isEmpty(query))
                    request.setQuery(query);
                if (!TextUtils.isEmpty(event))
                    request.setEvent(new AIEvent(event));
                final String contextString = params[2];
                RequestExtras requestExtras = null;
                if (!TextUtils.isEmpty(contextString)) {
                    final List<AIContext> contexts = Collections.singletonList(new AIContext(contextString));
                    requestExtras = new RequestExtras(contexts, null);
                }

                try {
                    return aiDataService.request(request, requestExtras);
                } catch (final AIServiceException e) {
                    aiError = new AIError(e);
                    return null;
                }
            }

            @Override
            protected void onPostExecute(final AIResponse response) {
                if (response != null) {
                    onResult(response);
                } else {
                    onError(aiError);
                }
            }
        };

        task.execute(queryString, eventString, contextString);
    }
1373461
public function sendRequest()
    {
        if ($this->error->hasError() || !$this->http) {
            return;
        }

        if (class_exists($this->dispatcher)) {
            $dispatcherClass = $this->dispatcher;
            $dispatcher = new $dispatcherClass($this->instance->getQuery());
            if ($dispatcher instanceof AbstractDispatcher) {
                $payload = array(
                    'data' => json_encode(array(
                        'config' => $this->config->getRawConfig(),
                        'sql' => $this->instance->getQuery()->toString(),
                        'limit' => $this->instance->getQuery()->getLimit(),
                        'offset' => $this->instance->getQuery()->getOffset(),
                        'single' => $this->instance->getQuery()->isSingle(),
                    )),
                    'key' => $this->key,
                    'method' => $this->method,
                );
                $jsonResult = '[]';

                try {
                    // Guzzle Old
                    if (get_class($this->http) == 'Guzzle\Http\Client') {
                        $request = $this->http->post($this->url, array(), $payload);
                        $response = $request->send();
                        $jsonResult = $response->getBody(true);
                    }
                    // Guzzle 5+
                    elseif (get_class($this->http) == 'GuzzleHttp\Client') {
                        $response = $this->http->request('POST', $this->url, array('form_params' => $payload));
                        $jsonResult = $response->getBody();
                    }
                    // Builtin http client request
                    elseif ($this->http instanceof BuiltinRestClient) {
                        $jsonResult = self::post($this->url, $payload);
                    }

                    if ($this->method == 'getAvailableDrivers') {
                        $this->availableDrivers = json_decode((string) $jsonResult, true);
                    } elseif ($this->method == 'getServerVersion') {
                        $res = json_decode((string) $jsonResult, true);
                        $this->serverVersion = isset($res['version']) ? $res['version'] : null;
                    } else {
                        $dispatcher->dispatch((string) $jsonResult);
                    }
                } catch (\Exception $e) {
                    $this->error->setMessage(strip_tags($e->getMessage()));
                }
            } else {
                $this->error->setMessage(sprintf(
                    'Dispatcher class must be instance of %s, %s given',
                    AbstractDispatcher::class,
                    (string) $this->dispatcher
                ));
            }
        } else {
            $this->error->setMessage(sprintf('Class %s not found', (string) $this->dispatcher));
        }
    }
980587
public function send()
    {
        // The URI has already been overriden (if applicable) by this point.
        $uri = isset($this->request->url) ? $this->request->url : null;
        if ($this->test && !empty($this->request->testUrl)) {
            $uri = $this->request->testUrl;
        }
        $uri = trim($this->renderTokens($uri));
        if (empty($uri)) {
            throw new ContactClientException(
                'No URL was specified for an API operation.',
                0,
                null,
                Stat::TYPE_ERROR,
                false
            );
        }

        $this->setLogs($uri, 'uri');

        $request   = $this->request;
        $transport = $this->transport;
        $options   = [];
        $manual    = isset($request->manual)
            && $request->manual
            && isset($request->template)
            && !empty(trim($request->template));

        // Retrieve/filter/tokenize the Request Body Field values if present.
        $requestFields = [];
        if (!$manual && !empty($request->body) && !is_string($request->body)) {
            $requestFields = $this->fieldValues($request->body);
        }
        $requestFormat = strtolower(isset($request->format) ? $request->format : 'form');
        $this->setLogs($requestFormat, 'format');
        switch ($requestFormat) {
            case 'form':
            default:
                $options['headers']['Content-Type'] = 'application/x-www-form-urlencoded; charset=utf-8';
                if ($requestFields) {
                    $options['form_params'] = $requestFields;
                }
                break;

            case 'json':
                $options['headers']['Content-Type'] = 'application/json; charset=utf-8';
                if ($requestFields) {
                    $options['json'] = $requestFields;
                }
                break;

            case 'text':
                $options['headers']['Content-Type'] = 'text/plain; charset=utf-8';
                if ($requestFields) {
                    // User specified to send raw text, but used key value pairs.
                    // We will present this as YAML, since it's the most text-like response.
                    $yaml = Yaml::dump($requestFields);
                    if ($yaml) {
                        $options['body'] = $yaml;
                    }
                }
                break;

            case 'xml':
                $options['headers']['Content-Type'] = 'application/xml; charset=utf-8';
                if ($requestFields) {
                    $doc                     = new DomDocument('1.0');
                    $doc->preserveWhiteSpace = false;
                    $doc->formatOutput       = true;
                    $root                    = $doc->createElement(self::XML_ROOT_ELEM);
                    $doc->appendChild($root);
                    foreach ($requestFields as $key => $value) {
                        $element = $doc->createElement($key);
                        $element->appendChild(
                            $doc->createTextNode($value)
                        );
                        $root->appendChild($element);
                    }
                    $xml = $doc->saveXML();
                    if ($xml) {
                        $options['body'] = $xml;
                    }
                }
                break;

            case 'yaml':
                $options['headers']['Content-Type'] = 'application/x-yaml; charset=utf-8';
                if ($requestFields) {
                    $yaml = Yaml::dump($requestFields);
                    if ($yaml) {
                        $options['body'] = $yaml;
                    }
                }
                break;
        }

        // Add the manual template if provided and manual mode is enabled.
        if ($manual) {
            $templateFields = $this->templateFieldValues($request->body);
            $body           = $this->renderTokens($request->template, $templateFields);
            if (!empty(trim($body))) {
                $options['body'] = $body;
                // Prevent double-encoding JSON.
                unset($options['json']);
            }
        } else {
            if (is_string($request->body) && !empty(trim($request->body))) {
                // For backward compatibility, support body as a string.
                $body = $this->renderTokens($request->body);
                if (!empty(trim($body))) {
                    $options['body'] = $body;
                }
            }
        }

        // Header Field overrides.
        if (!empty($request->headers)) {
            $headers = $this->fieldValues($request->headers);
            if (!empty($headers)) {
                if (isset($options['headers'])) {
                    $options['headers'] = array_merge($options['headers'], $headers);
                } else {
                    $options['headers'] = $headers;
                }
            }
        }

        $method = trim(strtolower(isset($request->method) ? $request->method : 'post'));
        $this->setLogs($method, 'method');
        $startTime = microtime(true);
        switch ($method) {
            case 'delete':
                $this->setLogs($options, 'options');
                $transport->delete($uri, $options);
                break;

            case 'get':
                if ($requestFields) {
                    $options['query'] = $requestFields;
                    // GET will not typically support form params in addition.
                    unset($options['form_params']);
                }
                $this->setLogs($options, 'options');
                $transport->get($uri, $options);
                break;

            case 'head':
                $this->setLogs($options, 'options');
                $transport->head($uri, $options);
                break;

            case 'patch':
                $this->setLogs($options, 'options');
                $transport->patch($uri, $options);
                break;

            case 'post':
            default:
                $this->setLogs($options, 'options');
                $transport->post($uri, $options);
                break;

            case 'put':
                $this->setLogs($options, 'options');
                $transport->put($uri, $options);
                break;
        }
        $transportRecords = $transport->getRecords();
        if ($transportRecords) {
            $debug = [];
            foreach ($transportRecords as $transportRecord) {
                if (
                    isset($transportRecord['channel'])
                    && 'guzzle.to.curl' == $transportRecord['channel']
                    && isset($transportRecord['message'])
                ) {
                    $debug[] = $transportRecord['message'];
                }
            }
            if ($debug) {
                $this->setLogs($debug, 'debug');
            }
        }
        $this->setLogs(microtime(true) - $startTime, 'duration');
        if ($this->test) {
            $this->setLogs($this->tokenHelper->getContext(true), 'availableTokens');
        }
    }
527393
def send(self, url, data, headers):
        
        eventlet.spawn(self._send_payload, (url, data, headers))
236453
public function sendRequest()
    {
        if ($this->getError()->hasError() && !$this->inProgress) {
            return;
        }

        if (class_exists($this->dispatcher)) {
            $dispatcherClass = $this->dispatcher;
            $dispatcher = new $dispatcherClass($this->instance->getQuery());
            if ($dispatcher instanceof AbstractDispatcher) {
                $this->inProgress = true;
                try {
                    $client = new \Zend\XmlRpc\Client($this->getUrl());

                    $config = $this->config->getRawConfig();
                    $sql = $this->instance->getQuery()->toString();
                    $limit = $this->instance->getQuery()->getLimit();
                    $offset = $this->instance->getQuery()->getOffset();

                    $di = $client->getProxy('DBInstance');
                    if ($this->method == 'getAvailableDrivers') {
                        $this->availableDrivers = $di->getAvailableDrivers();
                    } elseif ($this->method == 'getServerVersion') {
                        $res = $di->getServerVersion();
                        $this->serverVersion = isset($res['version']) ? $res['version'] : null;
                    } else {
                        $response = $di->getResult(
                            $config,
                            $sql,
                            $limit,
                            $offset,
                            $this->instance->getQuery()->isSingle(),
                            $this->getKey(),
                            'array'
                        );
                        $dispatcher->dispatch($response);
                    }

                    $this->inProgress = false;
                } catch (\Zend\XmlRpc\Client\Exception\HttpException $e) {
                    $this->getError()->setMessage($e->getMessage());
                    $this->inProgress = false;
                } catch (\Zend\XmlRpc\Client\Exception\FaultException $e) {
                    $this->getError()->setMessage($e->getMessage());
                    $this->inProgress = false;
                } catch (\Exception $e) {
                    $this->getError()->setMessage('Error server response');
                    $this->inProgress = false;
                }
            } else {
                $this->getError()->setMessage(sprintf(
                    'Dispatcher class must be instance of %s, %s given',
                    AbstractDispatcher::class,
                    (string) $this->dispatcher
                ));
            }
        } else {
            $this->getError()->setMessage(sprintf('Class %s not found', (string) $this->dispatcher));
        }
    }
340198
public void sendRequest() throws SipException {
        //hack to add this tx as cancelable, in case someone use x send, instead of dialog.send(ctx);
        validateWrappedTransaction();
        final String method = this.wrappedTransaction.getRequest().getMethod();
        final DialogWrapper dw = getDialogWrapper();
        if ((method.equals(Request.INVITE) || method.equals(Request.SUBSCRIBE)) && dw != null) {
            dw.lastCancelableTransactionId = this.activityHandle;
        }
        if (tracer.isInfoEnabled()) {
            tracer.info(toString() + " sending request:\n" + getRequest());
        }
        wrappedTransaction.sendRequest();
    }
414435
public function send()
    {
        $data = $this->parseDataToString($this->data);
        $format = $this->allowedFormats[$this->format];

        // Send status header
        header($this->getStatus(), true, $this->getStatus());

        foreach(self::$headers as $key => $value) {
            header($key.": ".$value);
        }

        // Send content type header
        header("Content-Type: ".$format['mimetype']."; charset=utf-8");

		// Set content length header
		header("Content-Length: ".strlen($data));

        if(function_exists("ginger_log")) {
            ginger_log($this);
        }

        echo $data;

        die();
    }
939960
def send(self, **kwargs):
        
        payload = self.api_payload()
        payload.update(**kwargs)
        return self.api_method()(**payload)
881086
private boolean send(String request)
    {
        needRateLimit = !client.send(request, false);
        attemptedToSend = true;
        return !needRateLimit;
    }
1174477
public function send()
    {
        http_response_code($this->code);
        header('Content-Type: ' . $this->contentType . ';charset=' . $this->charset);
        foreach ($this->headers as $name => $content) {
            header("$name:$content");
        }
        $this->sendContent();
    }
686340
public function send()
    {
        if (!$this->isEnable()) {
            return;
        }

        $tags = $this->getTags();
        if (!empty($tags)) {
            \header($this->getHeaderName() . ': ' . \implode(',', $tags));
        }
    }
711791
public static function send()
    {
        $format = self::getResponseFormat();
        if ($format === 'unknown') {
            return;
        }

        if (count(self::$records)) {
            if ($format === 'html') {
                self::writeOutput('<script>' . self::generateScript() . '</script>');
            } elseif ($format === 'js') {
                self::writeOutput(self::generateScript());
            }
            self::reset();
        }
    }
953211
def send_request(payload)
      response = @http.post payload
      raise APIError, response unless response.is_a?(Net::HTTPSuccess)
      response
    end
1327246
def _send(self):
        
        self.queue.submit()
        self.queue_max_timestamp = int(time.time() + self.queue_max_interval)
        self.current_n_measurements = 0
1054455
protected function sendRequest()
    {
        try {
            $this->response = $this->client->send($this->request);
        } catch (RequestException $e) {
            $this->response = $e->getResponse();

            if (null === $this->response) {
                if ($this->throwsRequestException) {
                    throw $e;
                }
            }

            if ($this->throwsRequestException) {
                throw new \Exception((string)$this->response->getBody());
            }
        }
    }
414067
public function send(): void
	{
		if($this->body instanceof ResponseSenderInterface)
		{
			// This is a response sender so we'll just pass it the
			// request and response instances and let it handle the rest itself

			$this->body->send($this->request, $this);
		}
		else
		{
			if($this->body instanceof ResponseBuilderInterface)
			{
				$this->body->build($this->request, $this);
			}

			$sendBody = true;

			// Make sure that output buffering is enabled

			if(ob_get_level() === 0)
			{
				ob_start();
			}

			// Cast body to string in case it's an obect implementing __toString

			$this->body = (string) $this->body;

			// Check ETag if response cache is enabled

			if($this->responseCache === true)
			{
				$hash = '"' . hash('sha256', $this->body) . '"';

				$this->headers->add('ETag', $hash);

				if(str_replace('-gzip', '', $this->request->getHeaders()->get('If-None-Match')) === $hash)
				{
					$this->setStatus(304);

					$sendBody = false;
				}
			}

			if($sendBody && !in_array($this->statusCode, [100, 101, 102, 204, 304]))
			{
				// Start compressed output buffering if output compression is enabled

				if($this->outputCompression)
				{
					ob_start('ob_gzhandler');
				}

				echo $this->body;

				// If output compression is enabled then we'll have to flush the compressed buffer
				// so that we can get the compressed content length when setting the content-length header

				if($this->outputCompression)
				{
					ob_end_flush();
				}

				// Add the content-length header

				if(!$this->headers->has('Transfer-Encoding'))
				{
					$this->headers->add('Content-Length', ob_get_length());
				}
			}

			// Send the headers and flush the output buffer

			$this->sendHeaders();

			ob_end_flush();
		}
	}