aboutsummaryrefslogtreecommitdiff
path: root/Sources
diff options
context:
space:
mode:
Diffstat (limited to 'Sources')
-rw-r--r--Sources/swiftGopherClient/gopherRequestResponseHandler.swift20
1 files changed, 15 insertions, 5 deletions
diff --git a/Sources/swiftGopherClient/gopherRequestResponseHandler.swift b/Sources/swiftGopherClient/gopherRequestResponseHandler.swift
index 6cede51..8349c6e 100644
--- a/Sources/swiftGopherClient/gopherRequestResponseHandler.swift
+++ b/Sources/swiftGopherClient/gopherRequestResponseHandler.swift
@@ -88,12 +88,22 @@ final class GopherRequestResponseHandler: ChannelInboundHandler {
"Carriage Returns: \(carriageReturnCount), Newline + Carriage Returns: \(newlineCarriageReturnCount)"
)
- for line in response.split(separator: "\r\n") {
- let lineItemType = getGopherFileType(item: "\(line.first ?? " ")")
- let item = createGopherItem(
- rawLine: String(line), itemType: lineItemType, rawData: originalBytes)
- gopherServerResponse.append(item)
+ if carriageReturnCount == 0 {
+ for line in response.split(separator: "\n") {
+ let lineItemType = getGopherFileType(item: "\(line.first ?? " ")")
+ let item = createGopherItem(
+ rawLine: String(line), itemType: lineItemType, rawData: originalBytes)
+ gopherServerResponse.append(item)
+ }
+ } else {
+ for line in response.split(separator: "\r\n") {
+ let lineItemType = getGopherFileType(item: "\(line.first ?? " ")")
+ let item = createGopherItem(
+ rawLine: String(line), itemType: lineItemType, rawData: originalBytes)
+ gopherServerResponse.append(item)
+
+ }
}
print("done parsing")