Performs POST to supplied url of result's request.
@param url url to post to.
@param result result containing request, its response will be filled.
@param headers headers to add.
@param contentType contentType for request.
174756
public void doHttpPost(String url, HttpResponse result, Map<String, Object> headers, String contentType) {
        httpClient.post(url, result, headers, contentType);
    }
996958
public void writeContent(final OutputStream result) throws IOException
    {
        if(this.mode == MODE_SINGLE) {
        	headerAll.writeContent(result);
        } else if(this.mode == MODE_MULTIPLE) {
            if(headerFirst != null) {
            	headerFirst.writeContent(result);
            }
            if(headerLeft != null) {
                headerLeft.writeContent(result);
            }
            if(headerRight != null) {
                headerRight.writeContent(result);
            }
            if(headerAll != null) {
                headerAll.writeContent(result);
            }
        }
    }
968338
@Override
	public void write(T result, HttpServerRequest request, HttpServerResponse response) {

		if (result != null) {
			response.end(JsonUtils.toJson(result, io.vertx.core.json.Json.mapper));
		}
		else {
			response.end();
		}
	}
696130
public static void setContent(final HttpRequestBase req,
                                final byte[] content,
                                final String contentType) throws HttpException {
    if (content == null) {
      return;
    }

    if (!(req instanceof HttpEntityEnclosingRequestBase)) {
      throw new HttpException("Invalid operation for method " +
                                      req.getMethod());
    }

    final HttpEntityEnclosingRequestBase eem = (HttpEntityEnclosingRequestBase)req;

    final ByteArrayEntity entity = new ByteArrayEntity(content);
    entity.setContentType(contentType);
    eem.setEntity(entity);
  }
921771
static void addHeaders(HttpUriRequest req, String mimeType) {
    if (POST.equalsIgnoreCase(req.getMethod())) {
      req.addHeader(CONTENT_TYPE, FORM_ENCODED);
    }
    if (mimeType != null) req.setHeader(ACCEPT, mimeType);
  }
291851
private void setContentTypeHeader(final HttpResponse response, final URLConnection connection) {
    response.headers().set(CONTENT_TYPE, mimeTypesMap.getContentType(connection.getURL().getPath()));
  }
1304676
public static HttpConnection createPost(URI uri, String body, String contentType) {
        HttpConnection connection = Http.POST(uri, "application/json");
        if(body != null) {
            setEntity(connection, body, contentType);
        }
        return connection;
    }
1035285
public static void write(String text, String contentType) {
		setContentType(contentType);
		Writer writer = null;
		try {
			writer = getWriter();
			writer.write(text);
			writer.flush();
		} catch (IOException e) {
			throw new RenderException("Error when output to client!", e);
		} finally {
			IoUtil.close(writer);
		}
	}
1248060
HttpResponse _doHttpRequest(RequestType requestType, String url, String json) throws IOException {
        StringEntity entity = null;

        if (json != null) {
            entity = new StringEntity(json, StandardCharsets.UTF_8.name());
            entity.setContentEncoding(StandardCharsets.UTF_8.name());
            entity.setContentType(ContentType.APPLICATION_JSON.getMimeType());
        }
        switch (requestType) {
            case POST:

                HttpPost post = new HttpPost(url);
                post.setEntity(entity);

                post.setHeader(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken);
                return _httpClient.execute(post, _httpContext);
            case GET:

                HttpGet httpGet = new HttpGet(url);
                
                httpGet.setHeader(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken);
                return _httpClient.execute(httpGet, _httpContext);
            case DELETE:

                HttpDelete httpDelete = new HttpDelete(url);
                
                httpDelete.setHeader(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken);
                return _httpClient.execute(httpDelete, _httpContext);
            case PUT:

                HttpPut httpput = new HttpPut(url);

                httpput.setEntity(entity);
                httpput.setHeader(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken);
                return _httpClient.execute(httpput, _httpContext);
            default:
                throw new IllegalArgumentException(" Request Type " + requestType + " not a valid request type. ");
        }
    }
205294
public static void get(String url, HttpConsumer<HttpExchange> endpoint, MediaTypes... mediaTypes) {
        addResource(Methods.GET, url, endpoint, mediaTypes);
    }
1008932
@Override
	public void write(Iterable<QueryResult> results) {
		logger.debug("Export to '{}', proxy {} metrics {}", url, proxy, results);

		HttpURLConnection urlConnection = null;

		try {
			if (proxy == null) {
				urlConnection = (HttpURLConnection) url.openConnection();
			} else {
				urlConnection = (HttpURLConnection) url.openConnection(proxy);
			}
			urlConnection.setRequestMethod("POST");
			urlConnection.setDoInput(true);
			urlConnection.setDoOutput(true);
			urlConnection.setReadTimeout(stackdriverApiTimeoutInMillis);
			urlConnection.setRequestProperty("content-type", "application/json; charset=utf-8");
			urlConnection.setRequestProperty("x-stackdriver-apikey", apiKey);

			serialize(results, urlConnection.getOutputStream());
			int responseCode = urlConnection.getResponseCode();
			if (responseCode != 200 && responseCode != 201) {
				exceptionCounter.incrementAndGet();
				logger.warn("Failure {}:'{}' to send result to Stackdriver server '{}' with proxy {}", responseCode,
						urlConnection.getResponseMessage(), url, proxy);
			}
			if (logger.isTraceEnabled()) {
				IoUtils2.copy(urlConnection.getInputStream(), System.out);
			}
		} catch (Exception e) {
			exceptionCounter.incrementAndGet();
			logger.warn("Failure to send result to Stackdriver server '{}' with proxy {}", url, proxy, e);
		} finally {
			if (urlConnection != null) {
				try {
					InputStream in = urlConnection.getInputStream();
					IoUtils2.copy(in, IoUtils2.nullOutputStream());
					IoUtils2.closeQuietly(in);
					InputStream err = urlConnection.getErrorStream();
					if (err != null) {
						IoUtils2.copy(err, IoUtils2.nullOutputStream());
						IoUtils2.closeQuietly(err);
					}
					urlConnection.disconnect();
				} catch (IOException e) {
					logger.warn("Error flushing http connection for one result, continuing");
					logger.debug("Stack trace for the http connection, usually a network timeout", e);
				}
			}

		}
	}
562815
public void setResult(Result result) throws IllegalArgumentException
  {

    if (null == result)
      throw new IllegalArgumentException(XSLMessages.createMessage(XSLTErrorResources.ER_RESULT_NULL, null)); //"result should not be null");

    try
    {
//      ContentHandler handler =
//        m_transformer.createResultContentHandler(result);
//      m_transformer.setContentHandler(handler);
        SerializationHandler xoh = 
            m_transformer.createSerializationHandler(result);
        m_transformer.setSerializationHandler(xoh);
    }
    catch (javax.xml.transform.TransformerException te)
    {
      throw new IllegalArgumentException(XSLMessages.createMessage(XSLTErrorResources.ER_RESULT_COULD_NOT_BE_SET, null)); //"result could not be set");
    }

    m_result = result;
  }
101634
function prepareResults(contentTypes) {
  var results = _.reduce(contentTypes, function (result, contentType, key) {

    // If content type is string, treat is as content type id
    if(_.isString(contentType)){
      var id = contentType;
      contentType = {
        id: id
      }
    }
    contentType.name = key;
    result.push(contentType);
    return result;
  }, []);
  return when.resolve(results);
}
367363
protected OutputStream outputStream(String contentType, Map headers, int status) {
        try {
            RequestContext.setControllerResponse(new NopResponse(contentType, status));

            if (headers != null) {
                for (Object key : headers.keySet()) {
                    if (headers.get(key) != null)
                        RequestContext.getHttpResponse().addHeader(key.toString(), headers.get(key).toString());
                }
            }

            return RequestContext.getHttpResponse().getOutputStream();
        }catch(Exception e){
            throw new ControllerException(e);
        }
    }
573661
public void doHttpPut(String url, String templateName, Object model, HttpResponse result) {
        doHttpPut(url, templateName, model, result, null, XmlHttpResponse.CONTENT_TYPE_XML_TEXT_UTF8);
    }
691135
public static void setEntity(HttpConnection connnection, String body, String contentType) {
        connnection.requestProperties.put("Content-type", contentType);
        connnection.setRequestBody(body);
    }
806486
@Override
	protected boolean copyRequestedContentToResponse(String requestedPath, HttpServletResponse response,
			String contentType) throws IOException {

		boolean copyDone = false;
		if (isValidRequestedPath(requestedPath)) {

			try {
				writeContent(requestedPath, null, response);
				response.setContentType(contentType);
				copyDone = true;
			} catch (ResourceNotFoundException e) {
				// Nothing to do here
			}
		}

		return copyDone;
	}