Send POST request
423212
public static String post(String url, Map<String, String> queryParas, String data, Map<String, String> headers) {
		HttpURLConnection conn = null;
		try {
			conn = getHttpConnection(buildUrlWithQueryString(url, queryParas), POST, headers);
			conn.connect();
			
			OutputStream out = conn.getOutputStream();
			out.write(data != null ? data.getBytes(CHARSET) : null);
			out.flush();
			out.close();
			
			return readResponseString(conn);
		}
		catch (Exception e) {
			throw new RuntimeException(e);
		}
		finally {
			if (conn != null) {
				conn.disconnect();
			}
		}
	}
1301358
def post_request(path, options = {}, &block)
      loop do
        response = self.class.post(path, options, &block)

        if response.code == 400 && response.body =~ /Load in progress/
          # We can't send data too fast, when the previous request is still loaded we
          # have to wait so sleep 10 seconds and try again
          sleep(10)
        elsif response.code == 200
          return
        else
          raise('Bad Post')
        end
      end
    end
1345728
def post(self, request, *args, **kwargs):
        """"""
        kwargs['pk'] = request.user.id
        self.kwargs['pk'] = request.user.id
        return super().post(request, *args, **kwargs)
281354
function _sendRequest(method, uri, options, callback) {

        method(uri, options)
            .on('success', function(data, response) {
                if (data.result) {
                    callback(null, data.result);
                } else {
                    callback(null, data);
                }
            })
            .on('fail', function(err, response) {
                if (err) {
                    callback(err);
                } else {
                    callback(new Error('Request failed'));
                }
            })
            .on('error', function(err, response) {
                if (err) {
                    callback(err);
                } else {
                    callback(new Error('Request error'));
                }
            })
            .on('timeout', function(ms) {
                callback(new Error('Request timed out (' + ms + ')'));
            });
    }
334995
function post(url, data, successCallback, errorCallback) {
    const request = new XMLHttpRequest();

    request.open('POST', url, true);
    request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');

    request.onreadystatechange = () => {
        if (request.readyState === 4) {
            /* Only 2xx codes are successful for the POST request. */
            if ((request.status >= 200) && (request.status < 300)) {
                successCallback(request.responseText);
            } else {
                console.error(`POST (${url}): error ${request.status} ${request.statusText}`);
                errorCallback(request.status, request.statusText);
            }
        }
    };

    request.send(data);
}
1073781
def post(path, options = {}, headers = {}, raw = false)
      request(:post, path, options, headers, raw)
    end
1226386
function doPost(options, data, callback) {
  var buffer = '';
  var req = http.request(options, function(res) {
    res.setEncoding('utf8');
    res.on('data', function (chunk) {
      buffer += chunk;
    });
    res.on('end', function(err) {
      callback(err, buffer);
    });
  }).on('error', function(e) {
    callback(e);
  });

  if (data && data.length) {
    req.write(data);
  }
  req.end();
}
1158124
def post(self, url, data):
        '''  '''
        data.update({'key': self.APIKEY})
        req = r.post(url,
                     data    = json.dumps(data),
                     headers = self.headers,
                     auth    = self.auth)
        return self.process_request(req)
196872
def post(self, url, post_params=None):
        
        params = urlencode(post_params)
        logger.debug('Making POST request to %s with body %s', url, params)
        return self.oauth_session.post(url, data=params)
767119
def _post(self, url, data=None, json=None, params=None, headers=None):
        """"""
        url = self.clean_url(url)
        response = requests.post(url, data=data, json=json, params=params,
                                 headers=headers, timeout=self.timeout,
                                 verify=self.verify)
        return response
358790
def _send_request(self, request, **kwargs):
        """"""
        log.debug(LOG_CHECK, "Send request %s with %s", request, kwargs)
        log.debug(LOG_CHECK, "Request headers %s", request.headers)
        self.url_connection = self.session.send(request, **kwargs)
        self.headers = self.url_connection.headers
        self._add_ssl_info()
48974
private function sendRequest() {
        try {
            $ch = curl_init();

            curl_setopt($ch, CURLOPT_URL, $this->url);
            curl_setopt($ch, CURLOPT_HEADER, 1);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
            curl_setopt($ch, CURLOPT_CONNECTTIMEOUT ,0); 
            curl_setopt($ch, CURLOPT_TIMEOUT, 600);
            curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, (isset($this->opts['timeout']) && $this->opts['timeout']) ? $this->opts['timeout'] : self::CONNECT_TIMEOUT);
            curl_setopt($ch, CURLINFO_HEADER_OUT, true);
            if($this->method == self::METHOD_POST) {
                curl_setopt($ch, CURLOPT_POST, 1); 
                if($this->sendJson) {
                    $this->postData = json_encode($this->postData);
                }
                curl_setopt($ch, CURLOPT_POSTFIELDS, $this->postData); 
            }

            if($this->headerParam) {
                if($this->sendJson) {
                    $this->headerParam = array_merge($this->headerParam, [
                        'Content-Type: application/json',
                        'Content-Length:' . strlen($this->postData)
                    ]);
                }
                curl_setopt($ch, CURLOPT_HTTPHEADER, $this->headerParam);
            }

            $response = curl_exec($ch);
            if($response) {
                list($responseHeader, $body) = explode("\r\n\r\n", $response, 2);
                $this->body = $body;
                $this->responseHeader = $responseHeader;
            }
            $this->header = curl_getinfo($ch, CURLINFO_HEADER_OUT);
            $this->status = curl_getinfo($ch, CURLINFO_HTTP_CODE);

            if($this->debug) {
                $this->debugInfo['requestHeader'] = $this->header;
                $this->debugInfo['responseHeader'] = $this->responseHeader;
                $this->debugInfo['totalTime'] = curl_getinfo($ch, CURLINFO_TOTAL_TIME);
                $this->debugInfo['connectTime'] = curl_getinfo($ch, CURLINFO_CONNECT_TIME);
                $this->debugInfo['nameLookupTime'] = curl_getinfo($ch, CURLINFO_NAMELOOKUP_TIME);

                if($this->method == self::METHOD_POST) {
                    $this->debugInfo['postData'] = $this->postData;
                }
            }
            curl_close($ch);
        } catch(\Exception $e) {
            $this->debugInfo['exception'] = $e->getMessage();
        }
    }
918239
function sendRequest (args) {
  // { options, formData }
  const options = args.options
  const formData = args.formData
  return request(options.endpoint, formData).then(() => options)
}
76080
function(uri, data) {
      if (any(hook('posting', uri, data), haveStopped)) return
      var request = this.xhr()
      request.open('POST', uri, false)
      request.setRequestHeader('Content-Type', 'application/json')
      request.send(JSpec.JSON.encode(data))
    }
335964
def post(self):
        
        # type(data) = dict
        data = json.loads(self.request.body.decode())
        # type(method) = str
        method = data["method"]
        # type(params) = dict
        params = data["params"]
        if method == "sendmail":
            response = dispatch([sendmail],{'jsonrpc': '2.0', 'method': 'sendmail', 'params': [params], 'id': 1})
            #self.write(response)
        else:
            pass
210581
def post(self, uri, data, **kwargs):
        
        return self.request("POST", uri, data=data, **kwargs)
565798
def send(self):
        """"""
        success = False
        if self.method is None:
            raise ParamsError()
        try:
            if self.method == 'SEARCH':
                req = self._get_requests()
                _url = self.__NETEAST_HOST + self._METHODS[self.method]
                resp = req.post(_url, data=self.data)
                self._build_response(resp)
                self.response.ok = True
            else:
                if isinstance(self.data, dict):
                    data = encrypted_request(self.data)

                req = self._get_webapi_requests()
                _url = self.__NETEAST_HOST + self._METHODS[self.method]

                if self.method in ('USER_DJ', 'USER_FOLLOWS', 'USER_EVENT'):
                    _url = _url % self.params['uid']

                if self.method in ('LYRIC', 'MUSIC_COMMENT'):
                    _url = _url % self.params['id']
                # GET
                if self.method in ('LYRIC'):
                    resp = req.get(_url)
                else:
                    resp = req.post(_url, data=data)
                self._build_response(resp)
                self.response.ok = True
        except Exception as why:
            traceback.print_exc()
            print 'Requests Exception', why
            # self._build_response(why)
            self.response.error = why