diff options
author | Navan Chauhan <navanchauhan@gmail.com> | 2024-03-09 21:45:24 -0700 |
---|---|---|
committer | Navan Chauhan <navanchauhan@gmail.com> | 2024-03-09 21:45:24 -0700 |
commit | b1d4c766f4bdd0f5c37d72941a73b4f8b6a3272c (patch) | |
tree | 228c869952f6c7427ba8e18180a1c4333b6bf2d1 /Sources | |
parent | 8a83bc079c952809b4513baf69408c7907ca7933 (diff) |
Diffstat (limited to 'Sources')
-rw-r--r-- | Sources/swift-gopher/gopherHandler.swift | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/Sources/swift-gopher/gopherHandler.swift b/Sources/swift-gopher/gopherHandler.swift index a9a3167..8b7100d 100644 --- a/Sources/swift-gopher/gopherHandler.swift +++ b/Sources/swift-gopher/gopherHandler.swift @@ -37,7 +37,7 @@ final class GopherHandler: ChannelInboundHandler { var input = self.unwrapInboundIn(data) buffer.writeBuffer(&input) - print(buffer.readableBytes) + // print(buffer.readableBytes) if let requestString = buffer.getString(at: 0, length: buffer.readableBytes) { if requestString.firstIndex(of: "\r\n") != nil || requestString.firstIndex(of: "\n") != nil @@ -51,7 +51,8 @@ final class GopherHandler: ChannelInboundHandler { logger.warning("Unable to retrieve remote address") } - var processedRequestString: String = requestString + var processedRequestString: String = requestString.replacingOccurrences( + of: "\r\0", with: "") // Check for backspace or delete and process them if processedRequestString.contains(delChar) || processedRequestString.contains(backspaceChar) @@ -78,13 +79,13 @@ final class GopherHandler: ChannelInboundHandler { processedRequestString = processDeleteCharacter(processedRequestString) // Could just combine in one statement if asciiCode is changed to asciiCodes: [Int] } - // for character in requestString { // Helpful for debugging - // if let scalar = character.unicodeScalars.first, scalar.value < 128 { - // print("\(character): \(scalar.value)") - // } else { - // print("\(character): Not an ASCII character") - // } - // } +// for character in requestString { // Helpful for debugging +// if let scalar = character.unicodeScalars.first, scalar.value < 128 { +// print("\(character): \(scalar.value)") +// } else { +// print("\(character): Not an ASCII character") +// } +// } let response = processGopherRequest(processedRequestString) var outputBuffer: ByteBuffer |