get a Post response

@param queryUrl
@param params
- direct query parameters
@param token
- a token if any
@param pFormData
- the form data - either as multipart of urlencoded
@return - the client Response
@throws Exception
188670
public ClientResponse getPostResponse(String queryUrl, String params,
      TokenResult token, Object pFormDataObject) throws Exception {
    params = params.replace("|", "%7C");
    params = params.replace("+", "%20");  
    // modal handling of post
    FormDataMultiPart form = null;
    MultivaluedMap<String, String> lFormData = null;
    if (pFormDataObject instanceof FormDataMultiPart) {
      form = (FormDataMultiPart) pFormDataObject;
    } else {
      @SuppressWarnings("unchecked")
      Map<String, String> pFormData = (Map<String, String>) pFormDataObject;
      lFormData = new MultivaluedMapImpl();
      if (pFormData != null) {
        for (String key : pFormData.keySet()) {
          lFormData.add(key, pFormData.get(key));
        }
      }
    }
    if (token != null) {
      switch (token.tokenMode) {
      case token1_24:
        if (lFormData != null) {
          lFormData.add(token.tokenName, token.token);
        } else {
          form.field(token.tokenName, token.token);
        }
        break;
      default:
        params += token.asParam();
      }
    }
    Builder resource = getResource(queryUrl + params);
    // FIXME allow to specify content type (not needed for Mediawiki itself
    // but
    // could be good for interfacing )
    ClientResponse response = null;
    if (lFormData != null) {
      response = resource.type(MediaType.APPLICATION_FORM_URLENCODED_TYPE)
          .post(ClientResponse.class, lFormData);
    } else {
      response = resource.type(MediaType.MULTIPART_FORM_DATA_TYPE)
          .post(ClientResponse.class, form);
    }
    return response;
  }
555734
def PKCS_POST_query(self, req_hook, req_args):
        '''  '''
        # HTTP POST queries require keyManagerTokens and sessionTokens
        headers = {'Content-Type': 'application/json',
                   'sessionToken': self.__session__,
                   'keyManagerToken': self.__keymngr__}

        # HTTP POST query to keymanager authenticate API
        try:
            if req_args is None:
                response = requests.post(self.__url__ + req_hook,
                                         headers=headers,
                                         cert=(self.__crt__, self.__key__),
                                         verify=True)
            else:
                response = requests.post(self.__url__ + req_hook,
                                         headers=headers,
                                         data=req_args,
                                         cert=(self.__crt__, self.__key__),
                                         verify=True)
        except requests.exceptions.RequestException as err:
            self.logger.error(err)
            return '500', 'Internal Error in PKCS_RESTful.POST_query()'
        # return the token
        self.logger.debug('%s: %s' % (response.status_code, response.text))
        return response.status_code, response.text
875235
public static String doPost(String url, Map<String, String> header, String param) throws KeyManagementException,
            NoSuchAlgorithmException, IOException {

        String result = null;
        HttpClient httpClient = new SSLClient();
        httpClient.getParams().setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, Constant.DEFAULT_CONN_TIMEOUT);
        httpClient.getParams().setParameter(CoreConnectionPNames.SO_TIMEOUT, Constant.DEFAULT_READ_TIMEOUT);
        HttpPost httpPost = new HttpPost(url);
        Iterator iterator;
        if (header != null) {
            Set<String> keys = header.keySet();
            iterator = keys.iterator();

            while(iterator.hasNext()) {
                String key = (String)iterator.next();
                httpPost.setHeader(key, header.get(key));
            }
        }

        httpPost.setEntity(new StringEntity(param, Constant.DEFAULT_CHARSET));

        HttpResponse response = httpClient.execute(httpPost);

        if (response != null) {
            HttpEntity resEntity = response.getEntity();
            if (resEntity != null) {
                result = EntityUtils.toString(resEntity, Constant.DEFAULT_CHARSET);
            }
        }

        return result;
    }
623719
def token_submit(self, token_id, json_data={}):
        
        uri = 'tokens/%s' % token_id
        post_body = json.dumps(json_data)

        resp, body = self.post(uri, post_body)
        self.expected_success(200, resp.status)
        body = json.loads(body)
        return rest_client.ResponseBody(resp, body)
292580
function GET(uri, params) {
	const reqUrl = `${uri}${url.format({ query: params })}`;

	log(`request URL: ${reqUrl}`);

	return fetch(reqUrl)
		.then(function handleGetRequest(res) {
			const status = res.status;
			const statusText = res.statusText;

			log(`status code: ${status}`);
			log(`status text: ${statusText}`);

			if (status !== 200) {
				const err = new Error(`Request failed: ${statusText}`);

				err.status = status;

				throw err;
			}

			return res.json();
		})
		.then(data => {
			const posts = data.posts;

			log(`${posts.length} posts were fetched`);

			return posts;
		})
		.catch(err => {
			log('catched err: ', err);

			throw err;
		});
}
265202
public Api getActionResult(String action, String params) throws Exception {
    Api result = this.getActionResult(action, params, null, null);
    return result;
  }
157240
private HttpResponse getResponse(StringBuilder q, String _id) throws URISyntaxException, IOException,
            ClientProtocolException
    {
        URI uri = new URI(CouchDBConstants.PROTOCOL, null, httpHost.getHostName(), httpHost.getPort(), _id,
                q.toString(), null);
        HttpGet get = new HttpGet(uri);
        get.addHeader("Accept", "application/json");
        return httpClient.execute(httpHost, get, CouchDBUtils.getContext(httpHost));
    }
697983
function pForm (url, form){
    var options = {
        method: 'POST',
        uri: url,
        form: form,
        headers: {
            'content-type': 'application/x-www-form-urlencoded'
        }
    };
    return rp(options);
}
1299608
def formdata_post(url, fields):
    
    content_type, data = formdata_encode(fields)
    req = urllib2.Request(url, data)
    req.add_header('Content-Type', content_type)
    return urllib2.urlopen(req).read()
497775
public HttpClient post(String url) throws HelloSignException {
        if (getParams != null) {
            logger.warn("GET parameters set for a POST request, they will be ignored");
        }
        request = new HttpPostRequest(url, postFields, auth);
        request.execute();
        return this;
    }
608334
public static HttpResponse executePost(final String url,
                                           final String entity,
                                           final Map<String, Object> parameters) {
        return executePost(url, null, null, entity, parameters);
    }
932001
@Override
	public <T extends Resource> T post(final String uri, final Parameters params) {
		return doRequest(uri).set(params).post();
	}
865366
public static HttpResponse executeGet(final String url,
                                          final String basicAuthUsername,
                                          final String basicAuthPassword,
                                          final Map<String, Object> parameters) {
        try {
            return executeGet(url, basicAuthUsername, basicAuthPassword, parameters, new HashMap<>());
        } catch (final Exception e) {
            LOGGER.error(e.getMessage(), e);
        }
        return null;
    }
195519
function (url, formData, cb) {

            request.post({url: url, formData: formData}, function (error, response, body) {

                if (error) {
                    return cb(error);
                }

                if (response.statusCode == 200 || response.statusCode == 201) {

                    return cb(null, body);

                } else {

                    return cb(new Error('Server responded with error: ' + response.statusCode));

                }

            })

        }
235568
def post(self, url, postParameters=None, urlParameters=None):
        
        if urlParameters:
            url = url + "?" + self.getParameters(urlParameters)
        headers = {'Authorization':'GoogleLogin auth=%s' % self.auth_token,
                    'Content-Type': 'application/x-www-form-urlencoded'
                    }
        postString = self.postParameters(postParameters)
        req = requests.post(url, data=postString, headers=headers)
        return req.text
241606
static HttpData getSsoForm(String remoteEndpointUrl,
                               String paramName, String paramValue,
                               @Nullable String relayState) {
        requireNonNull(remoteEndpointUrl, "remoteEndpointUrl");
        requireNonNull(paramName, "paramName");
        requireNonNull(paramValue, "paramValue");

        final StringBuilder html = new StringBuilder();
        html.append(XHTML.get(0))
            .append(XHTML.get(1)).append(HTML_ESCAPER.escape(remoteEndpointUrl)).append(XHTML.get(2))
            .append(XHTML.get(3)).append(HTML_ESCAPER.escape(paramName))
            .append(XHTML.get(4)).append(HTML_ESCAPER.escape(paramValue)).append(XHTML.get(5));

        if (relayState != null) {
            html.append(XHTML.get(3)).append(RELAY_STATE)
                .append(XHTML.get(4)).append(HTML_ESCAPER.escape(relayState)).append(XHTML.get(5));
        }
        html.append(XHTML.get(6));

        return HttpData.ofUtf8(html.toString());
    }
589377
public static HttpResponse executePost(final String url,
                                           final String basicAuthUsername,
                                           final String basicAuthPassword,
                                           final String entity) {
        return executePost(url, basicAuthUsername, basicAuthPassword, entity, new HashMap<>());
    }