Selects the first matching supported sub protocol and add it the the headers of the exchange.
186058
protected final void selectSubprotocol(final WebSocketHttpExchange exchange) {
        String requestedSubprotocols = exchange.getRequestHeader(Headers.SEC_WEB_SOCKET_PROTOCOL_STRING);
        if (requestedSubprotocols == null) {
            return;
        }

        String[] requestedSubprotocolArray = PATTERN.split(requestedSubprotocols);
        String subProtocol = supportedSubprotols(requestedSubprotocolArray);
        if (subProtocol != null && !subProtocol.isEmpty()) {
            exchange.setResponseHeader(Headers.SEC_WEB_SOCKET_PROTOCOL_STRING, subProtocol);
        }

    }
428652
def add_header(self, name: str, value: _HeaderTypes) -> None:
        
        self._headers.add(name, self._convert_header_value(value))
299196
private short addTrackedHeader(final short index, final SipHeader header) {
        if (index != -1) {
            headers.set(index, header.ensure());
            return index;
        }
        return addHeader(header.ensure());
    }
582708
def add_response_headers(self, headers, **overrides):
        """"""
        response_headers = self.route.get('response_headers', {}).copy()
        response_headers.update(headers)
        return self.where(response_headers=response_headers, **overrides)
1180509
def insert(prev, protocol, options={})
      klass = check_protocol(protocol)

      nxt = prev.body
      header = klass.new(options.merge!(packet: self))
      add_header header, previous_header: prev
      idx = headers.index(prev) + 1
      headers[idx, 0] = header
      header[:body] = nxt
      self
    end
842513
public B addHttpHeaders(Headers<AsciiString, String, ?> httpHeaders) {
        requireNonNull(httpHeaders, "httpHeaders");
        this.httpHeaders.add(httpHeaders);
        return self();
    }
926147
def AddHeader(self, header, value):
        '''
        '''
        self.user_headers.append((header, value))
        return self
774452
private void addHeaders(HttpRequest request, Map<String, String> headers) {
		for (Map.Entry<String, String> key : headers.entrySet()) {
			request.addHeader(key.getKey(), key.getValue());
		}
	}
31839
def select_header_accept(self, accepts):
        
        if not accepts:
            return

        accepts = [x.lower() for x in accepts]

        if 'application/json' in accepts:
            return 'application/json'
        else:
            return ', '.join(accepts)
997002
def negotiate(cls, headers):
        
        # set lower keys
        headers = {k.lower(): v for k, v in headers.items()}

        accept = headers.get('accept', "*/*")

        parsed_accept = accept.split(";")
        parsed_accept = [i.strip() for i in parsed_accept]

        # Protobuffer (only one version)
        if all([i in parsed_accept for i in cls.PROTOBUF['default']]):
            return ProtobufFormat
        elif all([i in parsed_accept for i in cls.PROTOBUF['text']]):
            return ProtobufTextFormat
        # Text 0.0.4
        elif all([i in parsed_accept for i in cls.TEXT['0.0.4']]):
            return TextFormat
        # Text (Default)
        elif all([i in parsed_accept for i in cls.TEXT['default']]):
            return TextFormat
        # Default
        else:
            return cls.FALLBACK
1167263
def addOutHeaderInfo(self, name, type, namespace, element_type=0,
                         mustUnderstand=0):
        """"""
        headerinfo = HeaderInfo(name, type, namespace, element_type)
        if mustUnderstand:
            headerinfo.mustUnderstand = 1
        self.outheaders.append(headerinfo)
        return headerinfo
814296
public PactDslRequestWithPath headers(String firstHeaderName, String firstHeaderValue, String... headerNameValuePairs) {
        if (headerNameValuePairs.length % 2 != 0) {
            throw new IllegalArgumentException("Pair key value should be provided, but there is one key without value.");
        }
        requestHeaders.put(firstHeaderName, Collections.singletonList(firstHeaderValue));

        for (int i = 0; i < headerNameValuePairs.length; i+=2) {
          requestHeaders.put(headerNameValuePairs[i], Collections.singletonList(headerNameValuePairs[i+1]));
        }

        return this;
    }
87809
def add_headers(self, header_name, value, *values):
		
		if self.__ro_flag:
			raise RuntimeError('ro')
		header_name = self.normalize_name(header_name)
		if header_name not in self.__headers.keys():
			self.__headers[header_name] = [value]
		else:
			self.__headers[header_name].append(value)

		for single_value in values:
			self.__headers[header_name].append(single_value)
1246698
def add_header(self, name, value):
        
        self._headers.setdefault(_hkey(name), []).append(_hval(value))
156872
private function addHeadersForOptionsRequests()
    {
        // header for preflight cache expiry
        $maxAge = self::MAX_AGE;
        if (isset($this->options[self::HEADER_MAX_AGE])) {
            $maxAge = intval($this->options[self::HEADER_MAX_AGE]);
        }
        @header(self::HEADER_MAX_AGE.': '.$maxAge);

        // header for allowed request headers in cross origin requests
        $allowedHeaders = self::$allowedHeaders;
        if (isset($this->options[self::HEADER_ALLOW_HEADERS])) {
            $allowedHeaders = (array)$this->options[self::HEADER_ALLOW_HEADERS];
        }
        @header(self::HEADER_ALLOW_HEADERS.':'.implode(',', $allowedHeaders));

        // header for allowed HTTP methods in cross orgin requests
        $allowedMethods = self::$allowedMethods;
        if (isset($this->options[self::HEADER_ALLOW_METHODS])) {
            $allowedMethods = (array)$this->options[self::HEADER_ALLOW_METHODS];
        }
        @header(self::HEADER_ALLOW_METHODS.':'.implode(',', $allowedMethods));
    }
1134434
public PactDslRequestWithPath matchHeader(String header, String regex, String headerExample) {
        requestMatchers.addCategory("header").setRule(header, new RegexMatcher(regex));
        requestHeaders.put(header, Collections.singletonList(headerExample));
        return this;
    }
968894
protected function addProtocolPortIfNeeded(string $matched, array $parsed) : string
    {
        if ('' === $matched || '*' === $matched) {
            $return = $matched;

            return $return;
        }
        $protocol = 'https://';
        $port     = 0;
        if (true === isset($parsed['scheme'])) {
            $this->addLog('Parsed a protocol from origin: '.$parsed['scheme']);
            $protocol = $parsed['scheme'].'://';
        } else {
            $this->addLog('Unable to parse protocol/scheme from origin');
        }
        if (true === isset($parsed['port'])) {
            $this->addLog('Parsed a port from origin: '.$parsed['port']);
            $port = (int) $parsed['port'];
        } else {
            $this->addLog('Unable to parse port from origin');
        }

        if (0 === $port) {
            if ('https://' === $protocol) {
                $port = 443;
            } else {
                $port = 80;
            }
        }

        if (('http://' === $protocol && 80 === $port) || ('https://' === $protocol && 443 === $port)) {
            $return = $protocol.$matched;
        } else {
            $return = $protocol.$matched.':'.$port;
        }
        return $return;
    }