Assure this is a valid VLAN header instance.
553961
def _validate(self):
        """"""
        if self.tpid.value not in (EtherType.VLAN, EtherType.VLAN_QINQ):
            raise UnpackException
        return
902034
def validate_headers!(response)
      return unless headers
      headers.each do |name, value|
        if name.is_a? Symbol
          raise Exceptions::Validation.new(
            "Symbols are not supported in headers"
          )
        end

        unless response.headers.has_key?(name)
          raise Exceptions::Validation.new(
            "Header #{name.inspect} was required but is missing"
          )
        end

        case value
        when String
          if response.headers[name] != value
            raise Exceptions::Validation.new(
              "Header #{name.inspect}, with value #{value.inspect} does not match #{response.headers[name]}."
            )
          end
        when Regexp
          if response.headers[name] !~ value
            raise Exceptions::Validation.new(
              "Header #{name.inspect}, with value #{value.inspect} does not match #{response.headers[name].inspect}."
            )
          end
        end
      end
    end
1116480
def valid_address(address):
    
    if not address:
        return False

    components = str(address).split(':')
    if len(components) > 2 or not valid_hostname(components[0]):
        return False

    if len(components) == 2 and not valid_port(components[1]):
        return False

    return True
525938
def vlan_id(self):
        
        nicid = self.nicid
        if nicid:
            v = nicid.split('.')
            if len(v) > 1:
                return nicid.split('.')[1]
366921
private static boolean isApplicationHeader(String key) {
    // Don't allow HTTP/2 pseudo headers or content-type to be added by the application.
    return (!key.startsWith(":")
            && !CONTENT_TYPE_KEY.name().equalsIgnoreCase(key))
            && !USER_AGENT_KEY.name().equalsIgnoreCase(key);
  }
1250746
def validate_value(value)
      v = value.to_s
      return v unless v.include?("\n")
      raise HeaderError, "Invalid HTTP header field value: #{v.inspect}"
    end
711312
function verifyHeaders(headers, packetlist) {
  const checkHashAlgos = function(hashAlgos) {
    const check = packet => algo => packet.hashAlgorithm === algo;

    for (let i = 0; i < packetlist.length; i++) {
      if (packetlist[i].tag === enums.packet.signature && !hashAlgos.some(check(packetlist[i]))) {
        return false;
      }
    }
    return true;
  };

  let oneHeader = null;
  let hashAlgos = [];
  headers.forEach(function(header) {
    oneHeader = header.match(/Hash: (.+)/); // get header value
    if (oneHeader) {
      oneHeader = oneHeader[1].replace(/\s/g, ''); // remove whitespace
      oneHeader = oneHeader.split(',');
      oneHeader = oneHeader.map(function(hash) {
        hash = hash.toLowerCase();
        try {
          return enums.write(enums.hash, hash);
        } catch (e) {
          throw new Error('Unknown hash algorithm in armor header: ' + hash);
        }
      });
      hashAlgos = hashAlgos.concat(oneHeader);
    } else {
      throw new Error('Only "Hash" header allowed in cleartext signed message');
    }
  });

  if (!hashAlgos.length && !checkHashAlgos([enums.hash.md5])) {
    throw new Error('If no "Hash" header in cleartext signed message, then only MD5 signatures allowed');
  } else if (hashAlgos.length && !checkHashAlgos(hashAlgos)) {
    throw new Error('Hash algorithm mismatch in armor header and signature');
  }
}
94634
def is_valid(self, name, value):
        
        if name not in self.header_types:
            return False
        t = self.header_types[name]
        if t == ATTR_TYPE_DISCRETE:
            return isinstance(value, int)
        elif t == ATTR_TYPE_CONTINUOUS:
            return isinstance(value, (float, Decimal))
        return True
246471
def ensure_security_header(envelope, queue):
    
    (header,) = HEADER_XPATH(envelope)
    security = SECURITY_XPATH(header)
    if security:
        for timestamp in TIMESTAMP_XPATH(security[0]):
            queue.push_and_mark(timestamp)
        return security[0]
    else:
        nsmap = {
            'wsu': ns.wsuns[1],
            'wsse': ns.wssens[1],
        }
        return _create_element(header, 'wsse:Security', nsmap)
386971
def create_vlan(self, nexus_host, vlanid, vni):
        """"""

        starttime = time.time()
        path_snip, body_snip = self.start_create_vlan()
        body_snip = self.get_create_vlan(nexus_host, vlanid, vni, body_snip)
        body_snip = self.end_create_vlan(body_snip)

        self.send_edit_string(nexus_host, path_snip, body_snip)

        self.capture_and_print_timeshot(
            starttime, "create_vlan_seg",
            switch=nexus_host)
926385
def _verify_cert(self, sock: ssl.SSLSocket):
        ''''''
        # Based on tornado.iostream.SSLIOStream
        # Needed for older OpenSSL (<0.9.8f) versions
        verify_mode = self._ssl_context.verify_mode

        assert verify_mode in (ssl.CERT_NONE, ssl.CERT_REQUIRED,
                               ssl.CERT_OPTIONAL), \
            'Unknown verify mode {}'.format(verify_mode)

        if verify_mode == ssl.CERT_NONE:
            return

        cert = sock.getpeercert()

        if not cert and verify_mode == ssl.CERT_OPTIONAL:
            return

        if not cert:
            raise SSLVerificationError('No SSL certificate given')

        try:
            ssl.match_hostname(cert, self._hostname)
        except ssl.CertificateError as error:
            raise SSLVerificationError('Invalid SSL certificate') from error
1237612
def validate(self):
		""""""
		for header in self._requiredHeaders:
			if not self.headers.get(header, False):
				raise errors.ParseError('Missing Notification Header: ' + header)
574240
def create_vlan(self):
        """"""
        return Vlan(
            self.networkapi_url,
            self.user,
            self.password,
            self.user_ldap)
559519
def assert_headers(context):
    
    expected_headers = [(k, v) for k, v in row_table(context).items()]
    request = httpretty.last_request()
    actual_headers = request.headers.items()

    for expected_header in expected_headers:
        assert_in(expected_header, actual_headers)
116973
def has_header(self, hdrclass):
        '''
        
        '''
        if isinstance(hdrclass, str):
            return self.get_header_by_name(hdrclass) is not None
        return self.get_header(hdrclass) is not None
375025
def ensure_header(self, header: BlockHeader=None) -> BlockHeader:
        
        if header is None:
            head = self.get_canonical_head()
            return self.create_header_from_parent(head)
        else:
            return header
1221167
def valid_host_with_port(hostport):
    
    host, port = hostport.rsplit(":", 1) if ":" in hostport else (hostport, None)

    # first, validate host or IP
    if not valid_ipv4(host) and not valid_host(host):
        return False

    # now, validate port
    if port is not None and not valid_port(port):
        return False

    return True