Adds the `headers`-object to `xhr`-headers.

@method _setHeaders
@param xhr {Object} containing the xhr-instance
@param headers {Object} containing all headers
@param method {String} the request-method used
@private
164171
function(xhr, promise, headers, method) {
            // XDR cannot set requestheaders, only XHR:
            if (!xhr._isXDR) {
                console.log(NAME, '_setHeaders');
                var name;
                if ((method!=='POST') && (method!=='PUT')) {
                    // force GET-request to make a request instead of using cache (like IE does):
                    headers['If-Modified-Since'] = 'Wed, 15 Nov 1995 01:00:00 GMT';
                    // header 'Content-Type' should only be set with POST or PUT requests:
                    delete headers[CONTENT_TYPE];
                }
                // set all headers
                for (name in headers) {
                    xhr.setRequestHeader(name, headers[name]);
                }

                // in case of POST or PUT method: always make sure 'Content-Type' is specified
                ((method!=='POST') && (method!=='PUT')) || (headers && (CONTENT_TYPE in headers)) || xhr.setRequestHeader(CONTENT_TYPE, DEF_CONTENT_TYPE_POST);
            }
        }
624373
public HttpFileServiceBuilder setHeaders(Headers<AsciiString, String, ?> headers) {
        requireNonNull(headers, "headers");
        if (!headers.isEmpty()) {
            getOrCreateHeaders().setAll(headers);
        }
        return this;
    }
815479
def set_headers(self, headers):
        
        self.headers = []
        if 'order' in self.options:
            for element in self.options['order']:
                for header in headers:
                    if header['key'] == element:
                        self.headers.append(header)
                        break
        else:
            self.headers = headers
1290253
def init_body_buffer(self, method, headers):
        
        content_length = headers.get("CONTENT-LENGTH", None)

        if method in (HTTPMethod.POST, HTTPMethod.PUT):
            if content_length is None:
                raise HTTPErrorBadRequest("HTTP Method requires a CONTENT-LENGTH header")
            self.content_length = int(content_length)
            self.body_buffer = bytearray(0)

        elif content_length is not None:
            raise HTTPErrorBadRequest(
                "HTTP method %s may NOT have a CONTENT-LENGTH header"
            )
890502
function setHeadersFromObject (res, headers) {
  var keys = Object.keys(headers)
  for (var i = 0; i < keys.length; i++) {
    var k = keys[i]
    if (k) res.setHeader(k, headers[k])
  }
}
327189
public void setHeader(String header) {
        headerLabel.getElement().setInnerSafeHtml(SafeHtmlUtils.fromString(header));
        addStyleName(CssName.WITH_HEADER);
        ListItem item = new ListItem(headerLabel);
        UiHelper.addMousePressedHandlers(item);
        item.setStyleName(CssName.COLLECTION_HEADER);
        insert(item, 0);
    }
632572
public function invoke($uri, $method, array $headers = [])
    {
        $client   = new Client();
        $res      = $client->createRequest(strtoupper($method), url('/') . '/' . $uri, array_merge($headers, $this->getHeaders()));
        $response = $res->send();
        $types    = $response->getHeader('Content-Type')->toArray();
        $body     = $response->getBody(true);
        foreach ($types as $type) {
            if ($type == 'application/json' && function_exists('json_decode') and is_string($body)) {
                return json_decode($body);
            }
        }

        return $body;
    }
1291458
public T addHeaders(Map<String, String> headers) {
		if(CollectionUtil.isEmpty(headers)) {
			return (T)this;
		}
		
		for (Entry<String,String> entry : headers.entrySet()) {
			this.header(entry.getKey(), StrUtil.nullToEmpty(entry.getValue()), false);
		}
		return (T)this;
	}
1086909
function _createXhr(method, url, options) {
    var xhr = new XMLHttpRequest();

    xhr.open(method, url);

    // Setup headers, including the *Authorization* that holds the Api Key.
    for (var header in options.headers) {
      if (options.headers.hasOwnProperty(header)) {
        xhr.setRequestHeader(header, options.headers[header]);
      }
    }

    // Set timeout.
    if (options.timeout > 0) {
      xhr.timeout = options.timeout;
    }

    return xhr;
  }
579432
function prepXHR(method, url, headers, callback, withCredentials, type, manager) {
    var xhr = new XHR();
    var status;

    xhr.open(method, url, true);

    if (type) {
      xhr.type = type;
      headers['Content-Type'] = type;
    }

    angular.forEach(headers, function(value, key) {
      (value) ? xhr.setRequestHeader(key, value) : null;
    });

    manager.register(xhr);

    xhr.onreadystatechange = function() {
      if (xhr.readyState == 4) {
        manager.unregister(xhr);
        var response = xhr.response || xhr.responseText;
        callback(status = status || xhr.status, response, xhr.getAllResponseHeaders());
      }
    };

    if (withCredentials) {
      xhr.withCredentials = true;
    }
    return xhr;
  }
729342
@BuilderMethod
    public void setHttpHeaders(@NonNull Map<String, String> headers) {
        this.httpHeaders.clear();
        this.httpHeaders.putAll(headers);
    }
22027
function setHeadersFromArray (res, headers) {
  for (var i = 0; i < headers.length; i++) {
    res.setHeader(headers[i][0], headers[i][1])
  }
}
883546
function(data, method) {

	var urlencodedForm = true;
	
	if (typeof data == 'string') {
		this.ioData = data;
	} else if (typeof data == 'object' && data._node) {

		if (data.getAttribute('enctype')) {
			urlencodedForm = false;
		}
		
		this.ioData = new FormData(data._node);
	}

	var req = this.req,
		method = method || 'POST';

	req.open(method, this.url);

	//Send the proper header information along with the request
	// Send as form encoded if we do not have a file field
	if (urlencodedForm) {
		req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	}

	return this._run();
}
225372
function setHeaders (headers, ratelimit, XHeaders = false) {
  if (XHeaders) {
    headers['X-Rate-Limit-Limit'] = ratelimit.limit
    headers['X-Rate-Limit-Remaining'] = ratelimit.remaining > 0 ? ratelimit.remaining : 0
    headers['X-Rate-Limit-Reset'] = ratelimit.reset
  }

  // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After
  headers['Retry-After'] = Math.ceil(ratelimit.reset / 1000)
}
1254842
public function custom(string $method, string $uri, string $body='', array $headers=[])
  {
    $this->sendRequest($this->createRequest($method,$uri), $headers);

    return !is_null($this->getResponse());
  }
1192206
def pre_process_method_headers(method, headers):
    '''
        
    '''
    method = method.lower()

    # Standard WSGI supported headers
    _wsgi_headers = ["content_length", "content_type", "query_string",
                     "remote_addr", "remote_host", "remote_user",
                     "request_method", "server_name", "server_port"]

    _transformed_headers = {}

    # For every header, replace - to _, prepend http_ if necessary and convert
    # to upper case.
    for header, value in headers.items():

        header = header.replace("-", "_")
        header = "http_{header}".format(
            header=header) if header.lower() not in _wsgi_headers else header
        _transformed_headers.update({header.upper(): value})

    return method, _transformed_headers
1353478
function Headers(options) {
  if (!(this instanceof Headers))
    return new Headers(options);

  AbstractBlock.call(this);

  if (options)
    this.parseOptions(options);
}