From 8e0d1b53206569dfc00578a4a9cd0508d4476005 Mon Sep 17 00:00:00 2001 From: Orkhan Alikhanov Date: Sat, 15 Jul 2017 16:50:21 +0400 Subject: [PATCH] Fixed not correctly converting bytes into String --- Tests/HttpSwiftTests/HttpSwiftTests.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Tests/HttpSwiftTests/HttpSwiftTests.swift b/Tests/HttpSwiftTests/HttpSwiftTests.swift index 45d61a6..644b899 100644 --- a/Tests/HttpSwiftTests/HttpSwiftTests.swift +++ b/Tests/HttpSwiftTests/HttpSwiftTests.swift @@ -235,7 +235,8 @@ extension Requester { typealias ResponseString = (value: String, response: RequestSwift.Response?, error: Error?) func responseString(_ handlr: @escaping ( (ResponseString) -> Void)) { let h: ResponseHandler = { (res: RequestSwift.Response?, error: Error?) in - handlr((String(cString: res?.body ?? []), res, error)) + let bytes = res?.body ?? [UInt8]() + handlr((String(data: Data(bytes: bytes, count: bytes.count), encoding: .utf8)!, res, error)) } self.response(h) }