ContentLengthVerifier Update (#369)

Motivation:
Currently http2 ignores content length when handling a response to a HEAD request and handling a 304 response.

Modifications:
Changing ContentLengthVerifier and any functions called

---------

Co-authored-by: George Barnett <gbarnett@apple.com>
Co-authored-by: Cory Benfield <lukasa@apple.com>
This commit is contained in:
authored and GitHub committed 2023-02-02 10:36:43 +00:00
1 parent 54853906e2
commit b408ca74bf
10 files changed
+294 -103

No files matched your search

@@ -77,10 +77,11 @@ struct ConnectionStreamState {
/// - parameters:
/// - streamID: The ID of the pushed stream.
/// - remoteInitialWindowSize: The initial window size of the remote peer.
/// - requestVerb: the HTTP method used on the request
/// - throws: If the stream ID is invalid.
mutating func createRemotelyPushedStream(streamID: HTTP2StreamID, remoteInitialWindowSize: UInt32) throws {
mutating func createRemotelyPushedStream(streamID: HTTP2StreamID, remoteInitialWindowSize: UInt32, requestVerb: String?) throws {
try self.reserveServerStreamID(streamID)
let streamState = HTTP2StreamStateMachine(receivedPushPromiseCreatingStreamID: streamID, remoteInitialWindowSize: remoteInitialWindowSize)
let streamState = HTTP2StreamStateMachine(receivedPushPromiseCreatingStreamID: streamID, remoteInitialWindowSize: remoteInitialWindowSize, requestVerb: requestVerb)
self.activeStreams.insert(streamState)
}
@@ -93,9 +94,9 @@ struct ConnectionStreamState {
/// - streamID: The ID of the pushed stream.
/// - localInitialWindowSize: Our initial window size..
/// - throws: If the stream ID is invalid.
mutating func createLocallyPushedStream(streamID: HTTP2StreamID, localInitialWindowSize: UInt32) throws {
mutating func createLocallyPushedStream(streamID: HTTP2StreamID, localInitialWindowSize: UInt32, requestVerb: String?) throws {
try self.reserveServerStreamID(streamID)
let streamState = HTTP2StreamStateMachine(sentPushPromiseCreatingStreamID: streamID, localInitialWindowSize: localInitialWindowSize)
let streamState = HTTP2StreamStateMachine(sentPushPromiseCreatingStreamID: streamID, localInitialWindowSize: localInitialWindowSize, requestVerb: requestVerb)
self.activeStreams.insert(streamState)
}
@@ -50,10 +50,10 @@ extension ReceivingPushPromiseState {
}
let validateHeaderBlock = self.headerBlockValidation == .enabled
let requestVerb = headers.first(name: ":method")
do {
try self.streamState.createRemotelyPushedStream(streamID: childStreamID,
remoteInitialWindowSize: self.remoteInitialWindowSize)
remoteInitialWindowSize: self.remoteInitialWindowSize, requestVerb: requestVerb)
let result = self.streamState.modifyStreamState(streamID: originalStreamID, ignoreRecentlyReset: true) {
$0.receivePushPromise(headers: headers, validateHeaderBlock: validateHeaderBlock)
@@ -59,8 +59,8 @@ extension SendingPushPromiseState {
guard case .succeed = result.result else {
return result
}
try self.streamState.createLocallyPushedStream(streamID: childStreamID, localInitialWindowSize: self.localInitialWindowSize)
let requestVerb = headers.first(name: ":method")
try self.streamState.createLocallyPushedStream(streamID: childStreamID, localInitialWindowSize: self.localInitialWindowSize, requestVerb: requestVerb)
return result
} catch {
return StateMachineResultWithEffect(result: .connectionError(underlyingError: error, type: .protocolError), effect: nil)