Skip to content

Commit 6ff0a0c

Browse files
sichanyooSichan Yoo
andauthored
fix: Fix StreamableHttpBody's isEndOfStream bug (#929)
Co-authored-by: Sichan Yoo <[email protected]>
1 parent b5aef47 commit 6ff0a0c

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

Sources/SmithyStreams/StreamableHttpBody.swift

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,15 @@ public class StreamableHttpBody: IStreamable {
111111
}
112112

113113
public func isEndOfStream() -> Bool {
114-
do {
115-
return try self.position >= self.length()
116-
} catch {
117-
return false
114+
switch body {
115+
case .data(let data):
116+
guard let data = data else { return true }
117+
return position >= data.endIndex
118+
case .stream(let stream):
119+
guard let length = stream.length else { return false }
120+
return stream.position >= length
121+
case .noStream:
122+
return true
118123
}
119124
}
120125
}

0 commit comments

Comments
 (0)