POST请求

@param url 请求的URL
@param body 内容正文

@return 响应内容

@since 1.1.0
355144
public static String post(String url, String body) {
        return request(HttpRequest.post(replaceLocalHost(url)), body).body();
    }
1322776
public HttpRequest body(String body, String contentType) {
		body(StrUtil.bytes(body, this.charset));
		this.form = null; // 当使用body时，停止form的使用
		contentLength((null != body ? body.length() : 0));

		if (null != contentType) {
			// Content-Type自定义设置
			this.contentType(contentType);
		} else {
			// 在用户未自定义的情况下自动根据内容判断
			contentType = HttpUtil.getContentTypeByRequestBody(body);
			if (null != contentType && ContentType.isDefault(this.header(Header.CONTENT_TYPE))) {
				if (null != this.charset) {
					// 附加编码信息
					contentType = ContentType.build(contentType, this.charset);
				}
				this.contentType(contentType);
			}
		}

		// 判断是否为rest请求
		if (StrUtil.containsAnyIgnoreCase(contentType, "json", "xml")) {
			this.isRest = true;
		}
		return this;
	}
549716
public function post(string $url, $params = null): HttpResponse
    {
        return $this->send('POST', $url, [
            $this->bodyFormat => $params,
        ]);
    }
636106
public String doPut(String url, String body) throws IOException {
        HttpPut httpPut = new HttpPut(getWsapiUrl() + url);
        httpPut.setEntity(new StringEntity(body, "utf-8"));
        return doRequest(httpPut);
    }
337846
def http_post(url, data)
    req = HTTPI::Request.new(:url => url, :body => data)
    return HTTPI.post(req).body
  end
515404
public RequestResponse doPost(String url, Map<String, Object> headers,
            Map<String, Object> urlParams, Object requestData) {
        RequestResponse rr = initRequestResponse("POST", url, headers, urlParams, requestData);
        Request.Builder requestBuilder = buildRequest(url, headers, urlParams)
                .post(buildRequestBody(rr));
        return doCall(client, requestBuilder.build(), rr);
    }
814570
protected Response httpPost(String path, String body, int status) {
        return httpRequest(status, null).body(body).post(baseURL + PATH_PREFIX + path);
    }
489331
def post(self, url, body=None):
        """"""
        response = self.http_request(url, 'POST', body or self, {'Content-Type': 'application/xml; charset=utf-8'})
        if response.status not in (200, 201, 204):
            self.raise_http_error(response)

        self._url = response.getheader('Location')

        if response.status in (200, 201):
            response_xml = response.read()
            logging.getLogger('recurly.http.response').debug(response_xml)
            self.update_from_element(ElementTree.fromstring(response_xml))
459524
function(url, body, func) {
  if (typeof url !== 'object') {
    url = parse(url);
  }

  if (!func) {
    func = body;
    body = undefined;
  }

  var opt = {
    host: url.hostname,
    port: url.port || 80,
    path: url.pathname
    //agent: false
  };

  if (body) {
    opt.headers = {
      'Content-Type': 'application/xml; charset=utf-8',
      'Content-Length': Buffer.byteLength(body),
      'Range': 'bytes=0-5120'
    };
    opt.method = 'POST';
  } else {
    opt.method = 'GET';
  }

  var req = http.request(opt);
  req.on('response', function(res) {
    var decoder = new StringDecoder('utf8')
      , total = 0
      , body = ''
      , done = false;

    var end = function() {
      if (done) return;
      done = true;
      res.body = body;
      func(null, res);
    };

    res.on('data', function(data) {
      total += data.length;
      body += decoder.write(data);
      if (total > 5120) {
        res.destroy();
        end();
      }
    }).on('error', function(err) {
      res.destroy();
      func(err);
    });

    res.on('end', end);

    // an agent socket's `end` sometimes
    // wont be emitted on the response
    res.socket.on('end', end);
  });
  req.end(body);
}
206522
function post(data, url) {
            var xmlhttp;
            try {
                // Opera 8.0+, Firefox, Safari
                xmlhttp = new XMLHttpRequest();
            } catch (e) {
                // Internet Explorer Browsers
                try {
                    xmlhttp = new ActiveXObject('Msxml2.XMLHTTP');
                } catch (e) {
                    try {
                        xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');
                    } catch (e) {
                        // Something went wrong
                        return false;
                    }
                }
            }

            xmlhttp.open('POST', url, true);
            var cookieName = cookie;
            xmlhttp.onreadystatechange = function () {
                if (xmlhttp.readyState === 4) {
                    if (xmlhttp.status === 200) {
                        document.cookie = cookieName + '=; expires=Thu, 01 Jan 1970 00:00:00 UTC';
                    }
                }
            };
            xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
            xmlhttp.send(data);
        }
171371
public static String get(String url,
                             Map<String, String> header,
                             Map<String, String> param) throws IOException {

        // 参数
        if (param != null) {
            url += "?" + Utils.getUrlParamsByMap(param);
        }

        HttpURLConnection httpUrlConn = httpUrlConn(url);
        httpUrlConn.setDoInput(true);
        httpUrlConn.setRequestMethod(Constant.RequestMethodGet);

        // header
        if (header != null) {
            header(header, httpUrlConn);
        }

        httpUrlConn.connect();

        return readIO(httpUrlConn);
    }
848477
public String postRequest(final URL url, final String jsonBody) throws MovieDbException {
        try {
            HttpPost httpPost = new HttpPost(url.toURI());
            httpPost.addHeader(HTTP.CONTENT_TYPE, APPLICATION_JSON);
            httpPost.addHeader(HttpHeaders.ACCEPT, APPLICATION_JSON);
            StringEntity params = new StringEntity(jsonBody, ContentType.APPLICATION_JSON);
            httpPost.setEntity(params);

            return validateResponse(DigestedResponseReader.postContent(httpClient, httpPost, CHARSET), url);
        } catch (URISyntaxException | IOException ex) {
            throw new MovieDbException(ApiExceptionType.CONNECTION_ERROR, null, url, ex);
        }
    }
912593
def post_resource(url, body):
    
    response = Bridge_DAO().postURL(url, PHEADER, body)
    log_data = "POST %s %s ==status==> %s" % (url, body, response.status)

    if response.status != 200 and response.status != 201:
        # 201 Created
        _raise_exception(log_data, url, response)

    _log_resp(log_data, response.data)
    return response.data
988874
public String doPost(String url, String body) throws IOException {
        HttpPost httpPost = new HttpPost(getWsapiUrl() + url);
        httpPost.setEntity(new StringEntity(body, "utf-8"));
        return doRequest(httpPost);
    }
998716
def post(self, url, headers=None, body=None, kwargs=None):
        
        return self._request(
            method='post',
            url=url,
            headers=headers,
            body=body,
            kwargs=kwargs
        )
1289895
public static String post(String urlString, String body) {
		return post(urlString, body, HttpRequest.TIMEOUT_DEFAULT);
	}
103073
def post(self, url, entity):
        

        try:
            if entity is None or entity == "":
                jsonData = ""
            else:
                jsonData = entity.to_json()
        except Exception as e:
            jsonData = jsonpickle.pickler.encode(entity)
        response = requests.post(
            self.host + url,
            jsonData,
            headers={
                "Content-Type": "application/json",
                'Authorization': 'Bearer ' + self.token,
                'x-falkonry-source':self.sourceHeader
            },
            verify=False
        )
        if response.status_code == 201:
            try:
                return json.loads(response._content.decode('utf-8'))
            except Exception as e:
                return json.loads(response.content)
        elif response.status_code == 409:
            try:
                return json.loads(response._content.decode('utf-8'))
            except Exception as e:
                return json.loads(response.content)
        elif response.status_code == 401:
            raise Exception(json.dumps({'message':'Unauthorized Access'}))
        else:
            raise Exception(response.content)