post form

@param host
@param path
@param headers
@param queries
@param bodies
@return
@throws Exception
173835
public static String doPost(String host, String path,
                                Map<String, String> headers,
                                Map<String, String> queries,
                                Map<String, String> bodies) throws Exception {
        return EntityUtils.toString(doPostResponse(host, path, headers, queries, JsonUtils.toJSON(bodies)).getEntity(), "utf-8");
    }
182124
def post(self, path, query=None, data=None, redirects=True):
        
        return self.request('POST', path, query, data, redirects)
1304511
public JSONObject post(String path, JSONObject content, Map<String,String> headers)
            throws ServiceException, JSONException {
        String sub = getSegment(path, 4);
        if ("event".equals(sub)) {
            SlackEvent event = new SlackEvent(content);
            EventHandler eventHandler = getEventHandler(event.getType(), event);
            if (eventHandler == null) {
                throw new ServiceException("Unsupported handler type: " + event.getType()
                        + (event.getChannel() == null ? "" : (":" + event.getChannel())));
            }
            return eventHandler.handleEvent(event);
        } else {
            // action/options request
            SlackRequest request = new SlackRequest(content);
            String userId = getAuthUser(headers);
            // TODO: ability to map request.getUser() to corresponding MDW user
            String callbackId = request.getCallbackId();
            if (callbackId != null) {
                int underscore = callbackId.lastIndexOf('_');
                if (underscore > 0) {
                    String handlerType = callbackId.substring(0, underscore);
                    String id = callbackId.substring(callbackId.lastIndexOf('/') + 1);
                    ActionHandler actionHandler = getActionHandler(handlerType, userId, id,
                            request);
                    if (actionHandler == null)
                        throw new ServiceException("Unsupported handler type: " + handlerType);

                    return actionHandler.handleRequest(userId, id, request);
                }
            }
            throw new ServiceException(ServiceException.BAD_REQUEST, "Bad or missing callback_id");
        }
    }
767403
protected function post(string $path, array $params = [], array $headers = [])
    {
        $body = self::createJsonBody($params);

        if ($body) {
            $headers = self::addJsonContentType($headers);
        }

        return $this->postRaw($path, $body, $headers);
    }
1286810
protected void doPost(String path) throws ClientException {
        this.readLock.lock();
        try {
            ClientResponse response = getResourceWrapper().rewritten(path, HttpMethod.POST)
                    .post(ClientResponse.class);
            errorIfStatusNotEqualTo(response, ClientResponse.Status.OK, ClientResponse.Status.NO_CONTENT);
            response.close();
        } catch (ClientHandlerException ex) {
            throw new ClientException(ClientResponse.Status.INTERNAL_SERVER_ERROR, ex.getMessage());
        } finally {
            this.readLock.unlock();
        }
    }
222393
public static String doPost(String host, String path, Map<String, String> body) throws Exception {
        return doPost(host, path, null, null, body);
    }
73574
def post(self, url, content='', files=None, params=None, extra_headers={}, upload_callback=None):
        ''
        if not url.startswith('http'):
            # relative url
            url = self.rootpath + url

        log.debug('posting content (len %s) to url %s', len(content) if content is not None else '?', url)
        headers = self.session.headers.copy()
        headers.update(**extra_headers)

        if not files is None:
            m = requests_toolbelt.MultipartEncoder(fields=files)
            if upload_callback is not None:
                m_len = m.len # compute value for callback closure
                def callback(monitor):
                    upload_callback(monitor, m_len)

                m = requests_toolbelt.MultipartEncoderMonitor(m, callback)
            headers['content-type'] = m.content_type
        else:
            m = content
        url = self.escapeUrl(url)
        r = self.session.post(url, data=m, params=params, headers=headers)
        if not r.ok:
            log.warning('HTTP POST failed: %s', r.text)
            raise JFSError(r.reason)
        return self.getObject(r)
81620
def post(self, url, data, headers={}):
        
        response = self._run_method('POST', url, data=data, headers=headers)
        return self._handle_response(url, response)
1074405
public void form_send_POST(OvhSafeKeyValue<String>[] form, String type) throws IOException {
		String qPath = "/contact/form/send";
		StringBuilder sb = path(qPath);
		HashMap<String, Object>o = new HashMap<String, Object>();
		addBody(o, "form", form);
		addBody(o, "type", type);
		execN(qPath, "POST", sb.toString(), o);
	}
545688
def post(path, obj, params = {}, headers = {}, auth = true)
      request(http_method: :post, path: path, body: obj, query: params, headers: headers, auth: auth)
    end
1263093
public static void post(String path, String acceptType, Route route) {
        getInstance().post(path, acceptType, route);
    }
167288
public function post($path, $postBody = null, array $parameters = [], $headers = [])
    {
        $response = $this->getClient()->getHttpClient()->post($path, $postBody, $parameters, $headers);

        return $this->decodeResponse($response);
    }
912639
public static HttpResponse doGetResponse(String host, String path,
                                             Map<String, String> headers,
                                             Map<String, String> queries) throws Exception {
        HttpClient httpClient = wrapClient(host);
        if (queries == null)
            queries = new HashMap<>();

        HttpGet request = new HttpGet(buildUrl(host, path, queries));

        if (headers == null) {
            headers = new HashMap<>();
            setHttpHeader(request);
        }

        for (Map.Entry<String, String> e : headers.entrySet()) {
            request.addHeader(e.getKey(), e.getValue());
        }
        return httpClient.execute(request);
    }
333056
def post(path, body)
      LOG.debug("post #{body} to \"#{path}\"")
      response = @access_token.post(path, body)
      parse_response(response)
    end
784590
def post(self, path, **kwargs):
        ''''''
        resp = self._session.post(self._url(path), **self._builder(**kwargs))
        if 'stream' in kwargs:
            return resp
        else:
            return self._resp_error_check(resp)
1333516
private static void formpostmultipart(
            Bootstrap bootstrap, String host, int port, URI uriFile, HttpDataFactory factory,
            Iterable<Entry<String, String>> headers, List<InterfaceHttpData> bodylist) throws Exception {
        // XXX /formpostmultipart
        // Start the connection attempt.
        ChannelFuture future = bootstrap.connect(SocketUtils.socketAddress(host, port));
        // Wait until the connection attempt succeeds or fails.
        Channel channel = future.sync().channel();

        // Prepare the HTTP request.
        HttpRequest request = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, uriFile.toASCIIString());

        // Use the PostBody encoder
        HttpPostRequestEncoder bodyRequestEncoder =
                new HttpPostRequestEncoder(factory, request, true); // true => multipart

        // it is legal to add directly header or cookie into the request until finalize
        for (Entry<String, String> entry : headers) {
            request.headers().set(entry.getKey(), entry.getValue());
        }

        // add Form attribute from previous request in formpost()
        bodyRequestEncoder.setBodyHttpDatas(bodylist);

        // finalize request
        bodyRequestEncoder.finalizeRequest();

        // send request
        channel.write(request);

        // test if request was chunked and if so, finish the write
        if (bodyRequestEncoder.isChunked()) {
            channel.write(bodyRequestEncoder);
        }
        channel.flush();

        // Now no more use of file representation (and list of HttpData)
        bodyRequestEncoder.cleanFiles();

        // Wait for the server to close the connection.
        channel.closeFuture().sync();
    }
1290305
public static void main(String[] args) throws Exception {
    if (args.length < 2)
      throw new IllegalArgumentException("must supply a path and set of host:port tuples");

    // Parse the address to which to bind the server.
    String[] mainParts = args[1].split(":");
    Address address = new Address(mainParts[0], Integer.valueOf(mainParts[1]));

    // Build a list of all member addresses to which to connect.
    List<Address> members = new ArrayList<>();
    for (int i = 1; i < args.length; i++) {
      String[] parts = args[i].split(":");
      members.add(new Address(parts[0], Integer.valueOf(parts[1])));
    }

    CopycatServer server = CopycatServer.builder(address)
      .withStateMachine(ValueStateMachine::new)
      .withTransport(new NettyTransport())
      .withStorage(Storage.builder()
        .withDirectory(args[0])
        .withMaxSegmentSize(1024 * 1024 * 32)
        .withMinorCompactionInterval(Duration.ofMinutes(1))
        .withMajorCompactionInterval(Duration.ofMinutes(15))
        .build())
      .build();

    server.serializer().register(SetCommand.class, 1);
    server.serializer().register(GetQuery.class, 2);
    server.serializer().register(DeleteCommand.class, 3);

    server.bootstrap(members).join();

    while (server.isRunning()) {
      Thread.sleep(1000);
    }
  }