agoo_http_header_ok(agooErr err, const char *key, int klen, const char *value, int vlen) {
    int		len = klen;
    int64_t	h = calc_hash(key, &len);
    Slot	*bucket = get_bucketp(h);
    Slot	s;
    bool	found = false;

    for (s = *bucket; NULL != s; s = s->next) {
	if (h == (int64_t)s->hash && len == (int)s->klen &&
	    ((0 <= len && len <= MAX_KEY_UNIQ) || 0 == strncasecmp(s->key, key, klen))) {
	    found = true;
	    break;
	}
    }
    if (!found) {
	char	buf[256];

	if ((int)sizeof(buf) <= klen) {
	    klen = sizeof(buf) - 1;
	}
	strncpy(buf, key, klen);
	buf[klen] = '\0';

	return agoo_err_set(err, AGOO_ERR_ARG, "%s is not a valid HTTP header key.", buf);
    }
    // Now check the value.
    found = false; // reuse as indicator for in a quoted string
    for (; 0 < vlen; vlen--, value++) {
	if ('o' != header_value_chars[(uint8_t)*value]) {
	    return agoo_err_set(err, AGOO_ERR_ARG, "%02x is not a valid HTTP header value character.", *value);
	}
	if ('"' == *value) {
	    found = !found;
	}
    }
    if (found) {
	return agoo_err_set(err, AGOO_ERR_ARG, "HTTP header has unmatched quote.");
    }
    return AGOO_ERR_OK;
}
agoo_http_header_ok(agooErr err, const char *key, int klen, const char *value, int vlen) {
    int		len = klen;
    int64_t	h = calc_hash(key, &len);
    Slot	*bucket = get_bucketp(h);
    Slot	s;
    bool	found = false;

    for (s = *bucket; NULL != s; s = s->next) {
	if (h == (int64_t)s->hash && len == (int)s->klen &&
	    ((0 <= len && len <= MAX_KEY_UNIQ) || 0 == strncasecmp(s->key, key, klen))) {
	    found = true;
	    break;
	}
    }
    if (!found) {
	char	buf[256];

	if ((int)sizeof(buf) <= klen) {
	    klen = sizeof(buf) - 1;
	}
	strncpy(buf, key, klen);
	buf[klen] = '\0';

	return agoo_err_set(err, AGOO_ERR_ARG, "%s is not a valid HTTP header key.", buf);
    }
     
    found = false;  
    for (; 0 < vlen; vlen--, value++) {
	if ('o' != header_value_chars[(uint8_t)*value]) {
	    return agoo_err_set(err, AGOO_ERR_ARG, "%02x is not a valid HTTP header value character.", *value);
	}
	if ('"' == *value) {
	    found = !found;
	}
    }
    if (found) {
	return agoo_err_set(err, AGOO_ERR_ARG, "HTTP header has unmatched quote.");
    }
    return AGOO_ERR_OK;
}