mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 07:14:30 +02:00
8195138: The asynchronous Http1HeaderParser doesn't handle all line folds correctly
Reviewed-by: chegar
This commit is contained in:
parent
99853dbf51
commit
424048c75f
4 changed files with 45 additions and 9 deletions
|
@ -213,9 +213,9 @@ class Http1HeaderParser {
|
|||
assert state == State.HEADER_FOUND_CR || state == State.HEADER_FOUND_LF;
|
||||
char c = (char)input.get();
|
||||
if (c == LF && state == State.HEADER_FOUND_CR) {
|
||||
String headerString = sb.toString();
|
||||
sb = new StringBuilder();
|
||||
addHeaderFromString(headerString);
|
||||
// header value will be flushed by
|
||||
// resumeOrSecondCR if next line does not
|
||||
// begin by SP or HT
|
||||
state = State.HEADER_FOUND_CR_LF;
|
||||
} else if (c == SP || c == HT) {
|
||||
sb.append(SP); // parity with MessageHeaders
|
||||
|
@ -229,11 +229,28 @@ class Http1HeaderParser {
|
|||
|
||||
private void resumeOrSecondCR(ByteBuffer input) {
|
||||
assert state == State.HEADER_FOUND_CR_LF;
|
||||
assert sb.length() == 0;
|
||||
char c = (char)input.get();
|
||||
if (c == CR) {
|
||||
if (sb.length() > 0) {
|
||||
// no continuation line - flush
|
||||
// previous header value.
|
||||
String headerString = sb.toString();
|
||||
sb = new StringBuilder();
|
||||
addHeaderFromString(headerString);
|
||||
}
|
||||
state = State.HEADER_FOUND_CR_LF_CR;
|
||||
} else if (c == SP || c == HT) {
|
||||
assert sb.length() != 0;
|
||||
sb.append(SP); // continuation line
|
||||
state = State.HEADER;
|
||||
} else {
|
||||
if (sb.length() > 0) {
|
||||
// no continuation line - flush
|
||||
// previous header value.
|
||||
String headerString = sb.toString();
|
||||
sb = new StringBuilder();
|
||||
addHeaderFromString(headerString);
|
||||
}
|
||||
sb.append(c);
|
||||
state = State.HEADER;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue