Build HTTP Headers.
160274
public function buildHeaders()
    {
        if ($this->use_cors) {
            if (strlen($this->cors_allow_origin) > 0) {
                header("Access-Control-Allow-Origin: $this->cors_allow_origin");
            }
            if ($this->cors_with_credentials) {
                header('Access-Control-Allow-Credentials: true');
            } else {
                header('Access-Control-Allow-Credentials: false');
            }
        }

        // Cache Control RFC: https://tools.ietf.org/html/rfc7234
        if ($this->nb_request instanceof CNabuHTTPRequest &&
            ($nb_site_target = $this->nb_request->getSiteTarget()) instanceof CNabuSiteTarget
        ) {
            if (($max_age = $nb_site_target->getDynamicCacheEffectiveMaxAge()) !== false) {
                $expire_date = gmdate("D, d M Y H:i:s", time() + $max_age);
                $this->setHeader('Expires', $expire_date . 'GMT');
                $this->setHeader('Cache-Control', "max-age=$max_age");
                $this->setHeader('User-Cache-Control', "max-age=$max_age");
                $this->setHeader('Pragma', 'cache');
            } else {
                $this->setHeader('Expires', 'Thu, 1 Jan 1981 00:00:00 GMT');
                $this->setheader('Cache-Control', 'no-store, no-cache, must-revalidate');
                $this->setHeader('Pragma', 'no-cache');
            }
            if ($nb_site_target->getAttachment() === 'T') {
                if (is_string($this->attachment_filename) && strlen($this->attachment_filename) > 0) {
                    $this->setHeader('Content-Disposition', 'attachment; filename=' . $this->attachment_filename);
                } else {
                    $this->setHeader('Content-Disposition', 'attachment');
                }
            }
        }

        if (($frame_options = $this->calculateFrameOptions()) !== null) {
            $this->setHeader('X-Frame-Options', $frame_options);
        }

        if (count($this->header_list) > 0) {
            foreach ($this->header_list as $name => $value) {
                header("$name: $value");
            }
        }
    }
640378
def cleanup_headers(self):
        """"""
        headers = {'Content-Type': 'application/json'}
        headers['Authorization'] = self.__token
        self.__headers = headers
        self.__params = {}
379538
def generate_headers(self, token):
        """"""
        headers = {}
        token = self.encode_token(token)
        if self.config["header"]:
            headers[self.config["header"]] = token
        if self.config["cookie"]:
            headers["Set-Cookie"] = dump_cookie(
                self.config["cookie"], token, httponly=True,
                max_age=self.config["expiration"]
            )
        return headers
163114
def get_headers(server):
    """"""
    try:
        response = requests.head(
            server, allow_redirects=False, verify=False, timeout=5)
    except requests.exceptions.ConnectionError:
        return False

    return dict(response.headers)
600081
public void setHttpHeaders(java.util.Collection<HttpHeader> httpHeaders) {
        if (httpHeaders == null) {
            this.httpHeaders = null;
            return;
        }

        this.httpHeaders = new java.util.ArrayList<HttpHeader>(httpHeaders);
    }
1167983
private function headers()
    {
        $headers = '';
        foreach (config('cors.headers') as $header) {
            $headers = $headers . $header . ', ';
        }
        header('Access-Control-Allow-Headers: ' . $headers);
    }
934351
protected function prepareHeaders()
    {
        // Need to let curl set the content type when posting. Our own content type
        // value would overwrite that.
        if ($this->method === HttpMethods::POST && !empty($this->headers["Content-Type"])) {
            unset($this->headers["Content-Type"]);
        }
        
        curl_setopt($this->curl, CURLOPT_USERAGENT, $this->userAgent);
        if (!empty($this->headers)) {
            $headers = $this->getHeadersBuilder()->normalize($this->headers);
            curl_setopt($this->curl, CURLOPT_HTTPHEADER, $headers);
        }
    }
842513
public B addHttpHeaders(Headers<AsciiString, String, ?> httpHeaders) {
        requireNonNull(httpHeaders, "httpHeaders");
        this.httpHeaders.add(httpHeaders);
        return self();
    }
975897
def to_header(self):
        """"""
        if self.date is not None:
            return http_date(self.date)
        if self.etag is not None:
            return quote_etag(self.etag)
        return ""
277667
private void appendHeaders(HttpHeaders headers, StringBuilder builder) {
        for (Entry<String, List<String>> headerEntry : headers.entrySet()) {
            builder.append(headerEntry.getKey());
            builder.append(":");
            builder.append(StringUtils.arrayToCommaDelimitedString(headerEntry.getValue().toArray()));
            builder.append(NEWLINE);
        }
    }
367821
def build_request(headers: Headers) -> str:
    
    raw_key = bytes(random.getrandbits(8) for _ in range(16))
    key = base64.b64encode(raw_key).decode()
    headers["Upgrade"] = "websocket"
    headers["Connection"] = "Upgrade"
    headers["Sec-WebSocket-Key"] = key
    headers["Sec-WebSocket-Version"] = "13"
    return key
1159439
def build_req_and_res(self):
        
        req = self.build_req(self, self.headers)
        res = self.build_res(self._handler)
        return req, res
219052
public HttpFileServiceBuilder addHeaders(Headers<AsciiString, String, ?> headers) {
        requireNonNull(headers, "headers");
        getOrCreateHeaders().add(headers);
        return this;
    }
624373
public HttpFileServiceBuilder setHeaders(Headers<AsciiString, String, ?> headers) {
        requireNonNull(headers, "headers");
        if (!headers.isEmpty()) {
            getOrCreateHeaders().setAll(headers);
        }
        return this;
    }
667122
def build_headers(self):
        '''
        
        '''
        if not 'Content-Type' in self.headers:
            content_type = self.content_type
            if self.encoding != DEFAULT_ENCODING:
                content_type += '; charset=%s' % self.encoding
            self.headers['Content-Type'] = content_type

        headers = list(self.headers.items())
        # Append cookies
        headers += [
            ('Set-Cookie', cookie.OutputString())
            for cookie in self.cookies.values()
        ]
        return headers
13361
def headers_to_include_from_request(curr_request):
    '''
        
    '''
    return {
        h: v for h, v in curr_request.META.items() if h in _settings.HEADERS_TO_INCLUDE}
994624
def add_cors_headers(request, response):
    """"""
    response.headerlist.append(('Access-Control-Allow-Origin', '*'))
    response.headerlist.append(
        ('Access-Control-Allow-Methods', 'GET, OPTIONS'))
    response.headerlist.append(
        ('Access-Control-Allow-Headers',
         ','.join(DEFAULT_ACCESS_CONTROL_ALLOW_HEADERS)))