httpPost.setHeaders(new Header[]{contentType, requestType});
HttpPost post = new HttpPost(uri); post.setEntity(((HttpPost) method).getEntity()); post.setHeaders(method.getAllHeaders()); method = post;
httpPost.setHeaders(new Header[]{contentType, requestType});
httpPost.setHeaders(getHeaders()); HttpEntity httpEntity = new NStringEntity(queryDslString, ContentType.APPLICATION_JSON); httpPost.setEntity(httpEntity);
logger.debug("Using url [{}]", url); HttpPost httpPost = new HttpPost(url); httpPost.setHeaders(getHeaders()); httpPost.setEntity(entity);
httpPost.setHeaders(getHeaders());
private HttpPost getPostMethod(String url, HttpEntity entity, Header[] headers) { HttpPost httppost = new HttpPost(url); httppost.setEntity(entity); httppost.setHeaders(headers); return httppost; }
private String doPost(URI uri, HttpEntity entity) throws DigitalOceanException, RequestUnsuccessfulException { HttpPost post = new HttpPost(uri); post.setHeaders(requestHeaders); if (null != entity) { post.setEntity(entity); } return executeHttpRequest(post); }
public <T> T post( URI uri, ValueReader<T> valueReader, @Nullable Iterable<? extends NameValuePair> parameters, @Nullable Header[] headers, @Nullable Charset charset ) throws IOException { HttpPost httpPost = new HttpPost(uri); httpPost.setEntity(new UrlEncodedFormEntity(parameters, charset)); httpPost.setHeaders(headers); return execute(httpPost, valueReader); }
private String doPost(URI uri, HttpEntity entity) throws DigitalOceanException, RequestUnsuccessfulException { HttpPost post = new HttpPost(uri); post.setHeaders(requestHeaders); if (null != entity) { post.setEntity(entity); } return executeHttpRequest(post); }
public static HttpResponse post(String url, Header[] headers, HttpEntity entity, int connectionTimeout, int connectionRequestTimeout, int socketTimeout) { CloseableHttpResponse response = null; CloseableHttpClient httpClient=null; try { httpClient = acceptsUntrustedCertsHttpClient(connectionTimeout, connectionRequestTimeout, socketTimeout); HttpPost post = new HttpPost(url); if (null != headers) { post.setHeaders(headers); } if (null != entity) { post.setEntity(entity); } response = httpClient.execute(post); } catch (Exception e) { e.printStackTrace(); throw new RuntimeException(e.getMessage()); } return response; }
public static HttpResponse post(String url, Header[] headers, HttpEntity entity) { CloseableHttpResponse response = null; CloseableHttpClient httpClient=null; try { httpClient = acceptsUntrustedCertsHttpClient(); HttpPost post = new HttpPost(url); if (null != headers) { post.setHeaders(headers); } if (null != entity) { post.setEntity(entity); } response = httpClient.execute(post); } catch (Exception e) { e.printStackTrace(); throw new RuntimeException(e.getMessage()); } return response; }
createPost("http://some/uri", "some payload", ContentType.DEFAULT_TEXT, new BasicHeader("header name", "header value")); static class RequestProducerImpl extends BasicAsyncRequestProducer { protected RequestProducerImpl( final HttpHost target, final HttpEntityEnclosingRequest request, final HttpAsyncContentProducer producer) { super(target, request, producer); } } public static HttpAsyncRequestProducer createPost( final String requestURI, final String content, final ContentType contentType, Header... headers) throws UnsupportedEncodingException { final HttpPost httppost = new HttpPost(requestURI); final NStringEntity entity = new NStringEntity(content, contentType); httppost.setEntity(entity); httppost.setHeaders(headers); final HttpHost target = URIUtils.extractHost(URI.create(requestURI)); return new RequestProducerImpl(target, httppost, entity); }
@Override public <T extends Response> T send( Request request, Class<T> responseType) throws IOException { byte[] payload = objectMapper.writeValueAsBytes(request); HttpPost httpPost = new HttpPost(this.url); httpPost.setEntity(new ByteArrayEntity(payload)); Header[] headers = buildHeaders(); httpPost.setHeaders(headers); ResponseHandler<T> responseHandler = getResponseHandler(responseType); try { return httpClient.execute(httpPost, responseHandler); } finally { httpClient.close(); } }
@Override public String post(URI uri, Header[] headers, HttpEntity body) throws IOException, SpotifyWebApiException { assert (uri != null); assert (!uri.toString().equals("")); final HttpPost httpPost = new HttpPost(); httpPost.setURI(uri); httpPost.setHeaders(headers); httpPost.setEntity(body); String responseBody = getResponseBody(execute(httpPost)); httpPost.releaseConnection(); return responseBody; }
public static CloseableHttpResponse doPost(final CloseableHttpClient cl, final URI uri, final Headers hdrs, final String contentType, final String content) throws IOException { final Headers headers = ensureHeaders(hdrs); if (contentType != null) { headers.add("Content-type", contentType); } final HttpPost httpPost = new HttpPost(uri); httpPost.setHeaders(hdrs.asArray()); if (content != null) { final StringEntity entity = new StringEntity(content); httpPost.setEntity(entity); } return cl.execute(httpPost); }
private static HttpResponse doPost(String resource, String body, Header[] headers, String base) throws Exception { DefaultHttpClient client = new DefaultHttpClient(); HttpPost post = new HttpPost(base + resource); if (headers != null) { post.setHeaders(headers); } if (body != null) { post.setEntity(new StringEntity(body)); } return client.execute(post); }
new BasicHeader("Content-type", "application/ld+json"), }; post.setHeaders(headers); post.setEntity(new StringEntity(jsonld));
public String post(String url, HttpEntity entity, Charset charset, Header[] headers, String proxyIp, int proxyPort, HttpClientContext httpClientContext) { HttpPost httpPost = new HttpPost(url); RequestConfig.Builder builder = RequestConfig.custom().setSocketTimeout(ProxyConstant.SOCKET_TIMEOUT) .setConnectTimeout(ProxyConstant.CONNECT_TIMEOUT) .setConnectionRequestTimeout(ProxyConstant.REQUEST_TIMEOUT).setRedirectsEnabled(true) .setCircularRedirectsAllowed(true); if (StringUtils.isNotEmpty(proxyIp)) { builder.setProxy(new HttpHost(proxyIp, proxyPort)); } httpPost.setConfig(builder.build()); if (headers != null && headers.length > 0) { httpPost.setHeaders(headers); } httpPost.setEntity(entity); try { return decodeHttpResponse(execute(httpPost, httpClientContext), charset, httpPost.getURI().getScheme() + httpPost.getURI().getHost()); } catch (IOException e) { return null; } }
public static Object post(ActionContext actionContext) throws Exception{ Thing self = (Thing) actionContext.get("self"); //URI String uri = (String) self.doAction("getUri", actionContext); //httpPost HttpPost httpPost = new HttpPost(uri); //headers Header[] headers = (Header[]) self.doAction("getHeaders", actionContext); if(headers != null){ httpPost.setHeaders(headers); } //params HttpParams params = (HttpParams) self.doAction("getHttpParams", actionContext); if(params != null){ httpPost.setParams(params); } //entity HttpEntity httpEntity = (HttpEntity) self.doAction("getHttpEntity", actionContext); if(httpEntity != null){ httpPost.setEntity(httpEntity); } HttpClientActions.initRequest(self, httpPost, actionContext); return doRequest(self, httpPost, actionContext); }