Issues HTTP HEAD request, returns response headers.

@param endpoint endpoint of request url
@param params   request line parameters

@return response headers

@throws IOException in case of any IO related issue
503173
public Header[] head(String endpoint, String params) throws IOException {
        return this.head(endpoint, params, "");
    }
379162
public Object postRequest(String restUrl, Map<String, String> params) throws IOException, WebServiceException {
		return this.postRequest(HttpMethod.POST, restUrl, params);
	}
1232091
function ApiClient(endpoint) {
    if (endpoint.length > 0 && endpoint.slice(-1) != "/") {
        endpoint += "/";
    }
    
    this.endpoint = endpoint;
    this.namespace = null;
}
1133548
public static void head(String url, HttpConsumer<HttpExchange> endpoint, MediaTypes... mediaTypes) {
        addResource(Methods.HEAD, url, endpoint, mediaTypes);
    }
665600
public RestResponse post(final String uri, final Map<String, Object> params)
            throws IOException, AppPlatformException {
        return request(getPath(uri), HttpPost.METHOD_NAME, params);
    }
436171
public PactDslRequestWithPath headers(Map<String, String> headers) {
      for (Map.Entry<String, String> entry: headers.entrySet()) {
        requestHeaders.put(entry.getKey(), Collections.singletonList(entry.getValue()));
      }
      return this;
    }
1300378
private static function make_request($endpoint, $values, $headers = array())
    {
        self::$ch = curl_init();
        $headers = array_merge(array("Content-Type: application/json"), $headers); // always pass the correct Content-Type header

        // send Api Version header
        if (!empty(self::$api_version)) {
            $headers[] = "Api-Version: " . self::$api_version;
        }

        curl_setopt(self::$ch, CURLOPT_USERAGENT, 'WePay v2 PHP SDK v' . self::VERSION . ' Client id:' . self::$client_id);
        curl_setopt(self::$ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt(self::$ch, CURLOPT_HTTPHEADER, $headers);
        curl_setopt(self::$ch, CURLOPT_TIMEOUT, 30); // 30-second timeout, adjust to taste
        curl_setopt(self::$ch, CURLOPT_POST, !empty($values)); // WePay's API is not strictly RESTful, so all requests are sent as POST unless there are no request values

        // Force TLS 1.2 connections
        curl_setopt(self::$ch, CURLOPT_SSL_VERIFYPEER, true);
        curl_setopt(self::$ch, CURLOPT_SSL_VERIFYHOST, 2);
        curl_setopt(self::$ch, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_2);

        $uri = self::getDomain() . $endpoint;
        curl_setopt(self::$ch, CURLOPT_URL, $uri);

        if (!empty($values)) {
            curl_setopt(self::$ch, CURLOPT_POSTFIELDS, json_encode($values));
        }

        $raw = curl_exec(self::$ch);
        if ($errno = curl_errno(self::$ch)) {
            // Set up special handling for request timeouts
            if ($errno == CURLE_OPERATION_TIMEOUTED) {
                throw new WePayServerException("Timeout occurred while trying to connect to WePay");
            }
            throw new Exception('cURL error while making API call to WePay: cURL Errno - ' . $errno . ', ' . curl_error(self::$ch), $errno);
        }

        $result = json_decode($raw);
        $httpCode = curl_getinfo(self::$ch, CURLINFO_HTTP_CODE);

        if ($httpCode >= 400) {
            if (!isset($result->error_code)) {
                throw new WePayServerException("WePay returned an error response with no error_code, please alert api@wepay.com. Original message: $result->error_description", $httpCode, $result, 0);
            }
            if ($httpCode >= 500) {
                throw new WePayServerException($result->error_description, $httpCode, $result, $result->error_code);
            }
            switch ($result->error) {
                case 'invalid_request':
                    throw new WePayRequestException($result->error_description, $httpCode, $result, $result->error_code);
                case 'access_denied':
                default:
                    throw new WePayPermissionException($result->error_description, $httpCode, $result, $result->error_code);
            }
        }

        return $result;
    }
761408
public static Header[] headUri(String uri) throws IOException {
        CloseableHttpClient c = newHttpClient(new URL(uri));
        HttpHead head = new HttpHead(uri);
        LOG.debug("HEAD {}", uri);
        CloseableHttpResponse res = c.execute(head, HttpClientContext.create());
        checkResponse(res);
        return res.getAllHeaders();
    }
762852
protected function getStream(string $endpoint, array $params)
    {
        $response = $this->requestRaw($endpoint, 'POST', ['json' => $params]);

        if (false !== stripos($response->getHeaderLine('Content-disposition'), 'attachment')) {
            return StreamResponse::buildFromPsrResponse($response);
        }

        return $this->castResponseToType($response, $this->app['config']->get('response_type'));
    }
1238982
protected function get($endpoint, $params = [])
    {
        if (array_key_exists('reply_markup', $params)) {
            $params['reply_markup'] = (string)$params['reply_markup'];
        }

        return $this->sendRequest(
            'GET',
            $endpoint,
            $params
        );
    }
230013
protected Response buildHeader(final WebApplicationService service, final Map<String, String> parameters) {
        return DefaultResponse.getHeaderResponse(service.getOriginalUrl(), parameters);
    }
1258106
function (endPoint, request, response) {
                var self = this,
                    context,
                    requestHandler,
                    handledWithErrorHandler = false,
                    buffers = [],
                    bufferLength = 0;

                // create a new application domain for the request
                var domain = Domain.create();

                domain.add(request);
                domain.add(response);

                // request.setEncoding('utf8');

                request.on('data', function (chunk) {
                    buffers.push(chunk);
                    bufferLength += chunk.length;
                });

                response.on('close', function () {
                    domain.dispose();
                });

                domain.on('error', handleError);


                request.on('end', function () {

                    request.body = new Buffer(bufferLength);

                    var pos = 0;

                    for (var i = 0; i < buffers.length; i++) {
                        buffers[i].copy(request.body, pos);
                        pos += buffers[i].length;
                    }

                    request.body.content = request.body.toString();

                    buffers = null;

                    domain.run(function () {
                        // create the new context object
                        context = new Context(self, endPoint, request, response);

                        // and set the chosen handler
                        requestHandler = self.$handlers.getRequestHandler(context);
                        context.handler = requestHandler;

                        flow()
                            .seq(function (cb) {
                                context._executeHook("beginRequest", cb);
                            })
                            .seq(function (cb) {
                                if (requestHandler.$.autoStartSession) {
                                    context.session.start(cb);
                                } else {
                                    cb();
                                }
                            })
                            .seq(function (cb) {
                                requestHandler.handleRequest(context, cb);
                            })
                            .exec(function (err) {
                                if (err) {
                                    handleError(err);
                                } else {
                                    context.response.end();
                                }
                            });
                    });
                });

                function handleError(err) {

                    if (!handledWithErrorHandler) {
                        handledWithErrorHandler = true;

                        var exceptionHandler = new ExceptionHandler(err);
                        try {
                            exceptionHandler.handleRequest(context, function (err) {
                                err && handleErrorTheHardWay(err);
                            });
                        } catch (e) {
                            handleErrorTheHardWay(err);
                        }

                    } else {
                        // error handler didn't do the job well
                        handleErrorTheHardWay(err);
                    }
                }

                function handleErrorTheHardWay(error) {

                    console.error(error);

                    try {
                        response.writeHead(500);
                    } catch (error) {
                        console.error('Error sending 500', error, request.url);
                    }

                    response.end('Internal Server Error');
                    domain.dispose();
                }

            }
52449
public String postJson(String endpoint, JSONObject json) throws IOException {
        return this.postJson(endpoint, "", json);
    }
1320279
public RequestTemplate headers(Map<String, Collection<String>> headers) {
    if (headers != null && !headers.isEmpty()) {
      headers.forEach(this::header);
    } else {
      this.headers.clear();
    }
    return this;
  }
538907
public function request($method, $endpoint, array $parameters = null)
    {
        $url = $this->config->getEndpoint() . $endpoint;

        // Client should always send OAuth2 tokens in its headers
        $headers = array('Authorization' => 'Bearer ' . $this->config->getAccessToken());

        return $this->client->request($method, $url, $parameters, $headers);
    }
222564
public function requestGet($endpoint, $params = array(), $headers = array())
    {
        return $this->getClient()->get($endpoint, $params, $headers);
    }
392075
protected void doHead(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        // Process request without content.
        processRequest(request, response, false);
    }