HttpHeader { public static HttpHeader parseHeader(byte[] content, int from, int to) throws InvalidHttpHeaderException { to = to >= content.length ? content.length : to; int fbi = -1; for(int i = from; i < to; i ++) { if (content[i] == ':') { fbi = i + 1; break; } } String fieldBody = null; String fieldName; if (fbi == -1) { fieldName = new String(content, from, to - from); } else { fieldName = new String(content, from, fbi - from - 1); fieldBody = new String(content, fbi, to - fbi).trim(); } return new HttpHeader(fieldName, fieldBody); } HttpHeader(String fieldName, String fieldBody);  HttpHeader(HttpHeaderDefinition headerDefinition, String fieldBody); static HttpHeader parseHeader(byte[] content, int from, int to); String getFieldName(); HttpHeaderDefinition getHeaderDefinition(); String getFieldBody(); byte[] toWireFormat(); @Override String toString();  }
@Test public void parseHeader() throws Exception { byte[] content = new byte[] {'A', ':', 'B', '\n', 'X'}; HttpHeader h = HttpHeader.parseHeader(content, 0, 3); assertEquals("A", h.getFieldName()); assertEquals("B", h.getFieldBody()); log.info(h.toString()); }