Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions Sources/OllamaKit/Utils/OKHTTPClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ internal extension OKHTTPClient {
.setFailureType(to: Error.self)
.eraseToAnyPublisher()
}
.handleEvents(receiveCancel: {
task.cancel()
})
.eraseToAnyPublisher()
}
}
Expand All @@ -131,8 +134,8 @@ private extension OKHTTPClient {
var isEscaped = false
var isWithinString = false
var nestingDepth = 0
var objectStartIndex = buffer.startIndex
let objectStartIndex = buffer.startIndex

for (index, byte) in buffer.enumerated() {
let character = Character(UnicodeScalar(byte))

Expand All @@ -146,9 +149,6 @@ private extension OKHTTPClient {
switch character {
case "{":
nestingDepth += 1
if nestingDepth == 1 {
objectStartIndex = index
}
case "}":
nestingDepth -= 1
if nestingDepth == 0 {
Expand Down