//put the extra bits into the new buffer
target.put((byte) extraData);
}
}
while (it != -1) {
HeaderValues values = headers.fiCurrent(it);
boolean skip = false;
if (firstPass) {
if (values.getHeaderName().byteAt(0) != ':') {
skip = true;
}
} else {
if (values.getHeaderName().byteAt(0) == ':') {
skip = true;
}
}
if (!skip) {
//initial super crappy implementation: just write everything out as literal header field never indexed
//makes things much simpler
for (int i = 0; i < values.size(); ++i) {
int required = 11 + values.getHeaderName().length(); //we use 11 to make sure we have enough room for the variable length itegers
StaticTableEntry[] staticTable = ENCODING_STATIC_TABLE.get(values.getHeaderName());
String val = values.get(i);
required += (1 + val.length());
if (target.remaining() < required) {
this.headersIterator = it;
this.currentBitPos = 0; //we don't use huffman yet
return State.UNDERFLOW;
}
if (staticTable == null) {
target.put((byte) 0);
target.put((byte) 0); //to use encodeInteger we need to place the first byte in the buffer.
encodeInteger(target, values.getHeaderName().length(), 7);
values.getHeaderName().appendTo(target);
} else {
boolean found = false;
for(StaticTableEntry st : staticTable) {
if(st.value != null && st.value.equals(val)) { //todo: some form of lookup?
target.put((byte) (1 << 7));