/** * Ensure that the dynamic table has enough room to hold 'headerSize' more bytes. * Removes the oldest entry from the dynamic table until sufficient space is available. */ private void ensureCapacity(int headerSize) throws IOException { while (size + headerSize > capacity) { int index = length(); if (index == 0) { break; } remove(); } }
/** * Ensure that the dynamic table has enough room to hold 'headerSize' more bytes. * Removes the oldest entry from the dynamic table until sufficient space is available. */ private void ensureCapacity(int headerSize) throws IOException { while (size + headerSize > capacity) { int index = length(); if (index == 0) { break; } remove(); } }
/** * 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); }
/** * 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; }