Skip to content

Commit

Permalink
Implement #8057 103 Early Hint
Browse files Browse the repository at this point in the history
updates from review
  • Loading branch information
gregw committed May 30, 2022
1 parent 41532ed commit 9d40cd4
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
Expand Up @@ -52,11 +52,11 @@ public void onResponse(HeadersFrame frame)
MetaData.Response response = (MetaData.Response)frame.getMetaData();
boolean valid;
if (response.getStatus() == HttpStatus.CONTINUE_100)
valid = validateAndUpdate(EnumSet.of(FrameState.INITIAL), FrameState.CONTINUE);
valid = validateAndUpdate(EnumSet.of(FrameState.INITIAL), FrameState.INFORMATIONAL);
else if (response.getStatus() == HttpStatus.EARLY_HINT_103)
valid = validateAndUpdate(EnumSet.of(FrameState.INITIAL, FrameState.HEADER, FrameState.CONTINUE), FrameState.CONTINUE);
valid = validateAndUpdate(EnumSet.of(FrameState.INITIAL, FrameState.HEADER, FrameState.INFORMATIONAL), FrameState.INFORMATIONAL);
else
valid = validateAndUpdate(EnumSet.of(FrameState.INITIAL, FrameState.CONTINUE), FrameState.HEADER);
valid = validateAndUpdate(EnumSet.of(FrameState.INITIAL, FrameState.INFORMATIONAL), FrameState.HEADER);
if (valid)
{
notIdle();
Expand Down
Expand Up @@ -315,7 +315,7 @@ public String toString()

protected enum FrameState
{
INITIAL, CONTINUE, HEADER, DATA, TRAILER, FAILED
INITIAL, INFORMATIONAL, HEADER, DATA, TRAILER, FAILED
}

private enum CloseState
Expand Down
Expand Up @@ -486,18 +486,18 @@ public void onHeaders(long streamId, HeadersFrame frame)
else if (metaData.isResponse())
{
MetaData.Response response = (MetaData.Response)metaData;
if (response.getStatus() != HttpStatus.CONTINUE_100 && response.getStatus() != HttpStatus.EARLY_HINT_103)
if (HttpStatus.isInformational(response.getStatus()))
{
// Expect DATA frames now.
parserDataMode = true;
parser.setDataMode(true);
if (LOG.isDebugEnabled())
LOG.debug("switching to parserDataMode=true for response {} on {}", metaData, this);
LOG.debug("staying in parserDataMode=false for response {} on {}", metaData, this);
}
else
{
// Expect DATA frames now.
parserDataMode = true;
parser.setDataMode(true);
if (LOG.isDebugEnabled())
LOG.debug("staying in parserDataMode=false for response {} on {}", metaData, this);
LOG.debug("switching to parserDataMode=true for response {} on {}", metaData, this);
}
}
else
Expand Down
Expand Up @@ -523,7 +523,7 @@ public void sendProcessing() throws IOException
* Send a 103 response as per <a href="https://datatracker.ietf.org/doc/html/rfc8297">RFC8297</a>
* This method is called by sendError if it is passed 103.
*
* @throws IOException if unable to send the 102 response
* @throws IOException if unable to send the 103 response
* @see javax.servlet.http.HttpServletResponse#sendError(int)
*/
public void sendEarlyHint() throws IOException
Expand Down

0 comments on commit 9d40cd4

Please sign in to comment.