/** * Remove and return the oldest header field from the dynamic table. */ public HeaderField remove() { HeaderField removed = headerFields[tail]; if (removed == null) { return null; } size -= removed.size(); headerFields[tail++] = null; if (tail == headerFields.length) { tail = 0; } return removed; }
/** * Add the header field to the dynamic table. * Entries are evicted from the dynamic table until the size of the table * and the new header field is less than the table's capacity. * If the size of the new entry is larger than the table's capacity, * the dynamic table will be cleared. */ private void add(byte[] name, byte[] value) { int headerSize = HeaderField.sizeOf(name, value); // Clear the table if the header field size is larger than the capacity. if (headerSize > capacity) { clear(); return; } // Evict oldest entries until we have enough capacity. while (size + headerSize > capacity) { remove(); } // Copy name and value that modifications of original do not affect the dynamic table. name = Arrays.copyOf(name, name.length); value = Arrays.copyOf(value, value.length); int h = hash(name); int i = index(h); HeaderEntry old = headerFields[i]; HeaderEntry e = new HeaderEntry(h, name, value, head.before.index - 1, old); headerFields[i] = e; e.addBefore(head); size += headerSize; }
private void insertHeader(HeaderListener headerListener, byte[] name, byte[] value, IndexType indexType) { addHeader(headerListener, name, value, indexType == IndexType.NEVER); switch (indexType) { case NONE: case NEVER: break; case INCREMENTAL: dynamicTable.add(new HeaderField(name, value)); break; default: throw new IllegalStateException("should not reach here"); } }
/** * Add the header field to the dynamic table. * Entries are evicted from the dynamic table until the size of the table * and the new header field is less than the table's capacity. * If the size of the new entry is larger than the table's capacity, * the dynamic table will be cleared. */ private void add(byte[] name, byte[] value) { int headerSize = HeaderField.sizeOf(name, value); // Clear the table if the header field size is larger than the capacity. if (headerSize > capacity) { clear(); return; } // Evict oldest entries until we have enough capacity. while (size + headerSize > capacity) { remove(); } // Copy name and value that modifications of original do not affect the dynamic table. name = Arrays.copyOf(name, name.length); value = Arrays.copyOf(value, value.length); int h = hash(name); int i = index(h); HeaderEntry old = headerFields[i]; HeaderEntry e = new HeaderEntry(h, name, value, head.before.index - 1, old); headerFields[i] = e; e.addBefore(head); size += headerSize; }
private void insertHeader(HeaderListener headerListener, byte[] name, byte[] value, IndexType indexType) { addHeader(headerListener, name, value, indexType == IndexType.NEVER); switch (indexType) { case NONE: case NEVER: break; case INCREMENTAL: dynamicTable.add(new HeaderField(name, value)); break; default: throw new IllegalStateException("should not reach here"); } }
/** * Remove and return the oldest header field from the dynamic table. */ public HeaderField remove() { HeaderField removed = headerFields[tail]; if (removed == null) { return null; } size -= removed.size(); headerFields[tail++] = null; if (tail == headerFields.length) { tail = 0; } return removed; }
int headerSize = HeaderField.sizeOf(name, value);
/** * Add the header field to the dynamic table. * Entries are evicted from the dynamic table until the size of the table * and the new header field is less than or equal to the table's capacity. * If the size of the new entry is larger than the table's capacity, * the dynamic table will be cleared. */ public void add(HeaderField header) { int headerSize = header.size(); if (headerSize > capacity) { clear(); return; } while (size + headerSize > capacity) { remove(); } headerFields[head++] = header; size += header.size(); if (head == headerFields.length) { head = 0; } }
int headerSize = HeaderField.sizeOf(name, value);
/** * Add the header field to the dynamic table. * Entries are evicted from the dynamic table until the size of the table * and the new header field is less than or equal to the table's capacity. * If the size of the new entry is larger than the table's capacity, * the dynamic table will be cleared. */ public void add(HeaderField header) { int headerSize = header.size(); if (headerSize > capacity) { clear(); return; } while (size + headerSize > capacity) { remove(); } headerFields[head++] = header; size += header.size(); if (head == headerFields.length) { head = 0; } }