ari-ban / issue-test

0 stars 0 forks source link

Race condition when a 100 continue is sent and shortly afterwards a 200 response. #1976

Closed arinban closed 6 years ago

arinban commented 6 years ago

When a server sends an expect 100 continue response and shortly afterwards a 200 OK response is sent, a race condition occurs because if the IOEvent involved is honored after the two messages are flushed to the buffer, the 200 response is ignored as it assumed that the message simply involved a 100 continue response. In those cases it should be verified if more that one message is present in the buffer in the state machine in decodeInitialLineFromBytes HttpClientFilter. Currently this is not verified so the second message is ignored.

                  if (httpResponse.getStatus() == 100) {

                        // reset the parsing state in preparation to parse
                        // another initial line which represents the final
                        // response from the server after it has sent a
                        // 100-Continue.
                        parsingState.offset += 2;
                        parsingState.start = parsingState.offset;
                        return false;
                    }
arinban commented 6 years ago
arinban commented 6 years ago

@fsgonz Commented I've created a PR with a possible fix for this issue.

https://github.com/javaee/grizzly/pull/1977

arinban commented 6 years ago

@fsgonz Commented In the changes included in the PR I verify if another response is pending in the buffer and "resets" the state machine in that case.

arinban commented 6 years ago

@rlubke Commented Thanks for the contribution.

arinban commented 6 years ago

@fsgonz Commented Thank you!