MCPcopy Create free account
hub / github.com/ebarlas/microhttp / parseHeader

Method parseHeader

src/main/java/org/microhttp/RequestParser.java:88–108  ·  view source on GitHub ↗
(byte[] token)

Source from the content-addressed store, hash-verified

86 }
87
88 private void parseHeader(byte[] token) {
89 if (token.length == 0) { // CR-LF on own line, end of headers
90 if (hasMultipleTransferLengths()) {
91 throw new IllegalStateException("multiple message lengths");
92 }
93 Integer contentLength = findContentLength();
94 if (contentLength == null) {
95 if (hasChunkedEncodingHeader()) {
96 state = State.CHUNK_SIZE;
97 } else {
98 body = EMPTY_BODY;
99 state = State.DONE;
100 }
101 } else {
102 this.contentLength = contentLength;
103 state = State.BODY;
104 }
105 } else {
106 headers.add(parseHeaderLine(token));
107 }
108 }
109
110 private static Header parseHeaderLine(byte[] line) {
111 int colonIndex = indexOfColon(line);

Callers

nothing calls this directly

Calls 5

findContentLengthMethod · 0.95
parseHeaderLineMethod · 0.95
addMethod · 0.45

Tested by

no test coverage detected