/*!
Sends POST request.
341895
function sendPOSTRequest( $server, $port, $serverMethod, $request, $timeout=30)
    {
        $pos = strpos($server, '://');
        if( $pos !== false )
            $server = substr($server, $pos+3);

        $fp = fsockopen( $server, $port, $errno, $errstr, $timeout );

        if( $fp )
        {
            $theCall    =   "POST $serverMethod HTTP/1.0\r\n"                       .
                            "Host: $server\r\n"                                   .
                            "Content-Type: application/x-www-form-urlencoded\r\n"   .
                            "Content-Length: ".strlen( $request )."\r\n\r\n"     .
                            $request."\r\n\r\n";

            if ( !fputs( $fp, "$theCall", strlen( $theCall ) ) )
            {
                $this->logger->writeTimedString( "Could not write to server socket: $server:$port", 'sendPOSTRequest failed' );
                return null;
            }

            return $this->handleResponse( $fp );
        }

        $this->logger->writeTimedString( "Unable to open socket on $server:$port. errno = $errno, errstr = $errstr", 'sendPOSTRequest failed' );
        return null;
    }
169333
function http($url, $post_data = null) {/*{{{*/
    $ch = curl_init();
    if (defined("CURL_CA_BUNDLE_PATH")) curl_setopt($ch, CURLOPT_CAINFO, CURL_CA_BUNDLE_PATH);
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
    curl_setopt($ch, CURLOPT_TIMEOUT, 30);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    //////////////////////////////////////////////////
    ///// Set to 1 to verify Server's SSL Cert //////
    //////////////////////////////////////////////////
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    if (isset($post_data)) {
      curl_setopt($ch, CURLOPT_POST, 1);
      curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
    }

    $response = curl_exec($ch);
    $this->http_status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    $this->last_api_call = $url;
    curl_close ($ch);

	/**
    echo "<pre>";
    echo $url . "\n";
    print_r(explode("&", $post_data)) . "\n";
    print_r($response) . "\n";
    echo "---\n</pre>";
	 */

    return $response;
  }
332287
def requests_post(url, data=None, json=None, **kwargs):
    """"""
    return requests_request('post', url, data=data, json=json, **kwargs)
346530
function _sendRequest($submit_data) {
    global $request_type;

    // Populate an array that contains all of the data to be sent to Authorize.net
    $submit_data = array_merge(array(
                         'x_login' => trim(MODULE_PAYMENT_AUTHORIZENET_AIM_LOGIN),
                         'x_tran_key' => trim(MODULE_PAYMENT_AUTHORIZENET_AIM_TXNKEY),
                         'x_relay_response' => 'FALSE',
                         'x_delim_data' => 'TRUE',
                         'x_delim_char' => $this->delimiter,  // The default delimiter is a comma
                         'x_encap_char' => $this->encapChar,  // The divider to encapsulate response fields
                         'x_version' => '3.1',  // 3.1 is required to use CVV codes
                         ), $submit_data);

    if(MODULE_PAYMENT_AUTHORIZENET_AIM_TESTMODE == 'Test') {
      $submit_data['x_test_request'] = 'TRUE';
    }

    // set URL
    $url = 'https://secure.authorize.net/gateway/transact.dll';
    $devurl = 'https://test.authorize.net/gateway/transact.dll';
    $dumpurl = 'https://developer.authorize.net/param_dump.asp';
    $certurl = 'https://certification.authorize.net/gateway/transact.dll';
    if (defined('AUTHORIZENET_DEVELOPER_MODE')) {
      if (AUTHORIZENET_DEVELOPER_MODE == 'on') $url = $devurl;
      if (AUTHORIZENET_DEVELOPER_MODE == 'echo' || MODULE_PAYMENT_AUTHORIZENET_AIM_DEBUGGING == 'echo') $url = $dumpurl;
      if (AUTHORIZENET_DEVELOPER_MODE == 'certify') $url = $certurl;
    }
    if (MODULE_PAYMENT_AUTHORIZENET_AIM_DEBUGGING == 'echo') $url = $dumpurl;

    // concatenate the submission data into $data variable after sanitizing to protect delimiters
    $data = '';
    while(list($key, $value) = each($submit_data)) {
      if ($key != 'x_delim_char' && $key != 'x_encap_char') {
        $value = str_replace(array($this->delimiter, $this->encapChar,'"',"'",'&amp;','&', '='), '', $value);
      }
      $data .= $key . '=' . urlencode($value) . '&';
    }
    // Remove the last "&" from the string
    $data = substr($data, 0, -1);


    // prepare a copy of submitted data for error-reporting purposes
    $this->reportable_submit_data = $submit_data;
    $this->reportable_submit_data['x_login'] = '*******';
    $this->reportable_submit_data['x_tran_key'] = '*******';
    if (isset($this->reportable_submit_data['x_card_num'])) $this->reportable_submit_data['x_card_num'] = str_repeat('X', strlen($this->reportable_submit_data['x_card_num'] - 4)) . substr($this->reportable_submit_data['x_card_num'], -4);
    if (isset($this->reportable_submit_data['x_card_code'])) $this->reportable_submit_data['x_card_code'] = '****';
    $this->reportable_submit_data['url'] = $url;


    // Post order info data to Authorize.net via CURL - Requires that PHP has CURL support installed

    // Send CURL communication
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_REFERER, ($request_type == 'SSL' ? HTTPS_SERVER . DIR_WS_HTTPS_CATALOG : HTTP_SERVER . DIR_WS_CATALOG ));
    curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_VERBOSE, 0);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_TIMEOUT, 15);
    curl_setopt($ch, CURLOPT_SSLVERSION, 3);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); /* compatibility for SSL communications on some Windows servers (IIS 5.0+) */
    if (CURL_PROXY_REQUIRED == 'True') {
      $this->proxy_tunnel_flag = (defined('CURL_PROXY_TUNNEL_FLAG') && strtoupper(CURL_PROXY_TUNNEL_FLAG) == 'FALSE') ? false : true;
      curl_setopt ($ch, CURLOPT_HTTPPROXYTUNNEL, $this->proxy_tunnel_flag);
      curl_setopt ($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
      curl_setopt ($ch, CURLOPT_PROXY, CURL_PROXY_SERVER_DETAILS);
    }

    $this->authorize = curl_exec($ch);
    $this->commError = curl_error($ch);
    $this->commErrNo = curl_errno($ch);

    $this->commInfo = @curl_getinfo($ch);
    curl_close ($ch);

    // if in 'echo' mode, dump the returned data to the browser and stop execution
    if ((defined('AUTHORIZENET_DEVELOPER_MODE') && AUTHORIZENET_DEVELOPER_MODE == 'echo') || MODULE_PAYMENT_AUTHORIZENET_AIM_DEBUGGING == 'echo') {
      echo $this->authorize . ($this->commErrNo != 0 ? '<br />' . $this->commErrNo . ' ' . $this->commError : '') . '<br />';
      die('Press the BACK button in your browser to return to the previous page.');
    }

    // parse the data received back from the gateway, taking into account the delimiters and encapsulation characters
    $stringToParse = $this->authorize;
    if (substr($stringToParse,0,1) == $this->encapChar) $stringToParse = substr($stringToParse,1);
    $stringToParse = preg_replace('/.{*}' . $this->encapChar . '$/', '', $stringToParse);
    $response = explode($this->encapChar . $this->delimiter . $this->encapChar, $stringToParse);

    return $response;
  }
370065
function send($object, $return = false)
    {
    	if (is_array($object))
    		$this->sendJson($object);

        $content = Silet::instance()->render($object.(
                (strpos($object, '.')===false?'.silet':'')));
        if ($return)
            return $content;

        echo $content;
    }
902332
public function send() {
    list ($headers, $blob, $code) = $this->toHttp();
    header('Content-Type: ' . Constants::MIME_TYPE);
    header("X-PHP-Response-Code: $code", TRUE, $code);
    foreach ($headers as $n => $v) {
      header("$n: $v");
    }
    echo $blob;
  }
196263
def send_post_command(self, command, body):
        """"""
        # Send commands via HTTP post
        res = requests.post("http://{host}:{port}{command}".format(
            host=self._host, port=self._receiver_port, command=command),
                            data=body, timeout=self.timeout)
        if res.status_code == 200:
            return res.text
        else:
            _LOGGER.error((
                "Host %s returned HTTP status code %s to POST command at "
                "end point %s"), self._host, res.status_code, command)
            return False
1245175
function post($url, $data, $callback = null)
    {
        $ret = new CoURLResult($url, $callback, $this->handle);
        $ret->method = self::METHOD_POST;
        $ret->data = $data;
        $this->requests[$ret->id] = $ret;
        return $ret;
    }
83346
function post($path, $body, $contentType = null)
    {
        return $this->dispatchRequest(
            $this->buildRequest('POST', $path, $body, $contentType)
        );
    }
1066608
function _send(level, args) {
  var payload = (
    'level=' + encodeURIComponent(level) +
    '&message=' + encodeURIComponent(args.join(' ')));

  var xhr = new XMLHttpRequest();
  xhr.open('POST', '/log');
  xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
  xhr.onreadystatechange = function () {
    // Check for error state
    if (xhr.readyState === 4 && xhr.status !== 200) {
      // TODO: Notify user on the page and show message if console.log doesn't exist
      if (console && console.log) {
        console.log(xhr.responseText);
      }
    }
  };
  xhr.send(payload);
}
1111231
function post($content) {
  // Iterate over the afterFns
  var i = 0,
      len = afterFns.length;
  for (; i < len; i++) {
    $content = afterFns[i].call(this, $content) || $content;
  }

  // Return tmpl
  return $content;
}
499221
function send_request($packet)
    {
        curl_setopt($this->curl, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($this->curl, CURLOPT_POSTFIELDS, $packet);
        $retval = curl_exec($this->curl);

        return $retval;
    }
297695
def post_request(url)
      do_request(url, Net::HTTP::Post) do |request|
        yield(request) if block_given?
      end
    end
1303646
public function send() {
		
		$url = $this->url();

		// Set fields for post or put requests.
		$this->curl = curl_init();
		curl_setopt($this->curl, CURLOPT_CUSTOMREQUEST, $this->method);
		if (in_array($this->method, ['POST', 'PUT'])) {
			$this->buildBody();
		} else {
			$this->header('Content-Type', null);
		}
		curl_setopt($this->curl, CURLOPT_URL, $url);
		curl_setopt($this->curl, CURLOPT_RETURNTRANSFER, true);

		// Capture rate limit response headers.
		$rate_limit = [];
		curl_setopt($this->curl, CURLOPT_HEADERFUNCTION, function ($curl, $header) use (&$rate_limit) {
			$parts = explode(':', trim($header), 2);
			if (isset($parts[1]) && preg_match('/^X-RateLimit-(.*)/', $parts[0], $match)) {
				$rate_limit[$match[1]] = (int) $parts[1];
			}
			return strlen($header);
		});

		// Set authorization.
		$access_token = $this->client->accessToken();
		if ($access_token === null) {
			$this->setBearerToken($this->client->id());
		} else {
			$this->setBearerToken($access_token);
		}

		// Add headers.
		$headers = [];
		foreach ($this->headers as $name => $value) {
			if ($value !== null) {
				$headers[] = $name . ': ' . $value;
			}
			curl_setopt($this->curl, CURLOPT_HTTPHEADER, $headers);
		}

		// Allow the client to access the request before it is sent.
		$before = $this->client->before();
		if (is_callable($before)) {
			$before($this);
		}

		// Get response,
		$body = @curl_exec($this->curl);

		// Allow the client to access the request after it is sent.
		$after = $this->client->after();
		if (is_callable($after)) {
			$after($this);
		}

		// Get status and error info before closing the handle.
		$http_status = curl_getinfo($this->curl, CURLINFO_HTTP_CODE);
		$error_code = curl_errno($this->curl);
		$error_message = curl_error($this->curl);
		@curl_close($this->curl);

		// Check for curl error.
		if ($error_code > 0) {
			throw new NetworkException($error_message, $error_code);
		}

		return new Response($body, $http_status, $rate_limit);
	}
574046
public function post($url=NULL, $postdata=NULL) {
		/* Do note that that if you are going to POST JSON you need to set the
		 * content-type of the transfer AFTER you set the postfields, this is done
		 * if you provide the postdata here, if not, take care to do it or the
		 * content-type will be wrong */
		$curl = curl_init();
		curl_setopt($curl, CURLOPT_FAILONERROR, FALSE);
		curl_setopt($curl, CURLOPT_FOLLOWLOCATION, FALSE);
		curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
		curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 5);
		curl_setopt($curl, CURLOPT_TIMEOUT, 30);
		curl_setopt($curl, CURLOPT_PORT, $this->api_port);

		if($this->api_is_https) {
			if(@CURLOPT_PROTOCOLS != 'CURLOPT_PROTOCOLS') {
				curl_setopt($curl, CURLOPT_PROTOCOLS, CURLPROTO_HTTPS);
			}
			curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2);
			curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, TRUE);
		} else {
			if(@CURLOPT_PROTOCOLS != 'CURLOPT_PROTOCOLS') {
				curl_setopt($curl, CURLOPT_PROTOCOLS, CURLPROTO_HTTP);
			}
		}
		if(isset($postdata)) {
			curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata);
		}
		curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/json; charset=utf-8'));
		curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'POST');
		curl_setopt($curl, CURLOPT_URL, $url);

		$body = curl_exec($curl);
		if($body === FALSE) {
			$error = curl_error($curl);
			if($error === NULL) {
				$error = 'Failed to connect to the Trusly API';
			}
			throw new Trustly_ConnectionException($error);
		}

		if($this->api_is_https) {
			$ssl_result = curl_getinfo($curl, CURLINFO_SSL_VERIFYRESULT);
			if($ssl_result !== 0) {

				$curl_x509_errors = array(
					'0' => 'X509_V_OK',
					'2' => 'X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT',
					'3' => 'X509_V_ERR_UNABLE_TO_GET_CRL',
					'4' => 'X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE',
					'5' => 'X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE',
					'6' => 'X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY',
					'7' => 'X509_V_ERR_CERT_SIGNATURE_FAILURE',
					'8' => 'X509_V_ERR_CRL_SIGNATURE_FAILURE',
					'9' => 'X509_V_ERR_CERT_NOT_YET_VALID',
					'10' => 'X509_V_ERR_CERT_HAS_EXPIRED',
					'11' => 'X509_V_ERR_CRL_NOT_YET_VALID',
					'12' => 'X509_V_ERR_CRL_HAS_EXPIRED',
					'13' => 'X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD',
					'14' => 'X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD',
					'15' => 'X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD',
					'16' => 'X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD',
					'17' => 'X509_V_ERR_OUT_OF_MEM',
					'18' => 'X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT',
					'19' => 'X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN',
					'20' => 'X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY',
					'21' => 'X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE',
					'22' => 'X509_V_ERR_CERT_CHAIN_TOO_LONG',
					'23' => 'X509_V_ERR_CERT_REVOKED',
					'24' => 'X509_V_ERR_INVALID_CA',
					'25' => 'X509_V_ERR_PATH_LENGTH_EXCEEDED',
					'26' => 'X509_V_ERR_INVALID_PURPOSE',
					'27' => 'X509_V_ERR_CERT_UNTRUSTED',
					'28' => 'X509_V_ERR_CERT_REJECTED',
					'29' => 'X509_V_ERR_SUBJECT_ISSUER_MISMATCH',
					'30' => 'X509_V_ERR_AKID_SKID_MISMATCH',
					'31' => 'X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH',
					'32' => 'X509_V_ERR_KEYUSAGE_NO_CERTSIGN',
					'50' => 'X509_V_ERR_APPLICATION_VERIFICATION'
				);

				$ssl_error_str = null;
				if(isset($curl_x509_errors[$ssl_result])) {
					$ssl_error_str = $curl_x509_errors[$ssl_result];
				}

				$error = 'Failed to connect to the Trusly API. SSL Verification error #' . $ssl_result . ($ssl_error_str?': ' . $ssl_error_str:'');
				throw new Trustly_ConnectionException($error);
			}
		}
		$response_code = curl_getinfo($curl, CURLINFO_HTTP_CODE);

		return array($body, $response_code);
	}
292259
final public function send()
    {
        if (!Str::equalIgnoreCase($this->_sendMethod, App::$Request->getMethod())) {
            return false;
        }

        return $this->getRequest('submit', $this->_sendMethod) !== null;
    }
412184
def post(self, endpoint, params=None, version='1.1', json_encoded=False):
        """"""
        return self.request(endpoint, 'POST', params=params, version=version, json_encoded=json_encoded)