@Override public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof HeaderField)) { return false; } HeaderField other = (HeaderField) obj; boolean nameEquals = HpackUtil.equals(name, other.name); boolean valueEquals = HpackUtil.equals(value, other.value); return nameEquals && valueEquals; }
HeaderField(byte[] name, byte[] value) { this.name = requireNonNull(name); this.value = requireNonNull(value); }
@Override public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof HeaderField)) { return false; } HeaderField other = (HeaderField) obj; boolean nameEquals = HpackUtil.equals(name, other.name); boolean valueEquals = HpackUtil.equals(value, other.value); return nameEquals && valueEquals; }
HeaderField(byte[] name, byte[] value) { this.name = requireNonNull(name); this.value = requireNonNull(value); }
/** * Returns the index value for the given header field in the static table. * Returns -1 if the header field is not in the static table. */ static int getIndex(byte[] name, byte[] value) { int index = getIndex(name); if (index == -1) { return -1; } // Note this assumes all entries for a given header field are sequential. while (index <= length) { HeaderField entry = getEntry(index); if (!HpackUtil.equals(name, entry.name)) { break; } if (HpackUtil.equals(value, entry.value)) { return index; } index++; } return -1; }
/** * Returns the index value for the given header field in the static table. * Returns -1 if the header field is not in the static table. */ static int getIndex(byte[] name, byte[] value) { int index = getIndex(name); if (index == -1) { return -1; } // Note this assumes all entries for a given header field are sequential. while (index <= length) { HeaderField entry = getEntry(index); if (!HpackUtil.equals(name, entry.name)) { break; } if (HpackUtil.equals(value, entry.value)) { return index; } index++; } return -1; }
/** * Returns the header entry with the lowest index value for the header field. * Returns null if header field is not in the dynamic table. */ private HeaderEntry getEntry(byte[] name, byte[] value) { if (length() == 0 || name == null || value == null) { return null; } int h = hash(name); int i = index(h); for (HeaderEntry e = headerFields[i]; e != null; e = e.next) { if (e.hash == h && HpackUtil.equals(name, e.name) && HpackUtil.equals(value, e.value)) { return e; } } return null; }
/** * Returns the header entry with the lowest index value for the header field. * Returns null if header field is not in the dynamic table. */ private HeaderEntry getEntry(byte[] name, byte[] value) { if (length() == 0 || name == null || value == null) { return null; } int h = hash(name); int i = index(h); for (HeaderEntry e = headerFields[i]; e != null; e = e.next) { if (e.hash == h && HpackUtil.equals(name, e.name) && HpackUtil.equals(value, e.value)) { return e; } } return null; }
/** * Returns the lowest index value for the header field name in the dynamic table. * Returns -1 if the header field name is not in the dynamic table. */ private int getIndex(byte[] name) { if (length() == 0 || name == null) { return -1; } int h = hash(name); int i = index(h); int index = -1; for (HeaderEntry e = headerFields[i]; e != null; e = e.next) { if (e.hash == h && HpackUtil.equals(name, e.name)) { index = e.index; break; } } return getIndex(index); }
/** * Returns the lowest index value for the header field name in the dynamic table. * Returns -1 if the header field name is not in the dynamic table. */ private int getIndex(byte[] name) { if (length() == 0 || name == null) { return -1; } int h = hash(name); int i = index(h); int index = -1; for (HeaderEntry e = headerFields[i]; e != null; e = e.next) { if (e.hash == h && HpackUtil.equals(name, e.name)) { index = e.index; break; } } return getIndex(index); }