public void emit(HttpField field) { int field_size = field.getName().length() + field.getValue().length(); size += field_size; if (size > maxSize) throw new BadMessageException( HttpStatus.REQUEST_ENTITY_TOO_LARGE_413, "Header size " + size + ">" + maxSize); if (field instanceof StaticTableHttpField) { StaticTableHttpField value = (StaticTableHttpField) field; switch (field.getHeader()) { case C_STATUS: status = (Integer) value.getStaticValue(); break; case C_METHOD: method = field.getValue(); break; case C_SCHEME: scheme = (HttpScheme) value.getStaticValue(); break; default: throw new IllegalArgumentException(field.getName()); } } else if (field.getHeader() != null) { switch (field.getHeader()) { case C_STATUS: status = field.getIntValue(); break; case C_METHOD: method = field.getValue(); break; case C_SCHEME: scheme = HttpScheme.CACHE.get(field.getValue()); break; case C_AUTHORITY: authority = (field instanceof HostPortHttpField) ? ((HostPortHttpField) field) : new AuthorityHttpField(field.getValue()); break; case HOST: // :authority fields must come first. If we have one, ignore the // host header as far as authority goes. if (authority == null) authority = (field instanceof HostPortHttpField) ? ((HostPortHttpField) field) : new AuthorityHttpField(field.getValue()); fields.add(field); break; case C_PATH: path = field.getValue(); break; case CONTENT_LENGTH: contentLength = field.getLongValue(); fields.add(field); break; default: if (field.getName().charAt(0) != ':') fields.add(field); } } else { if (field.getName().charAt(0) != ':') fields.add(field); } }