PR 426 - Fixing a test and removing debug prints (#590)
diff --git a/Foundation/NSURLSession/EasyHandle.swift b/Foundation/NSURLSession/EasyHandle.swift
index ea6c03f..dbc8ec7 100644
--- a/Foundation/NSURLSession/EasyHandle.swift
+++ b/Foundation/NSURLSession/EasyHandle.swift
@@ -311,7 +311,6 @@
///
/// - SeeAlso: https://curl.haxx.se/libcurl/c/curl_easy_pause.html
func pauseReceive() {
- URLSession.printDebug("[EasyHandle] pause receive (\(pauseState))")
guard !pauseState.contains(.receivePaused) else { return }
pauseState.insert(.receivePaused)
pauseState.setState(on: self)
@@ -322,7 +321,6 @@
/// will be called before this method returns.
/// - SeeAlso: https://curl.haxx.se/libcurl/c/curl_easy_pause.html
func unpauseReceive() {
- URLSession.printDebug("[EasyHandle] unpause receive (\(pauseState))")
guard pauseState.contains(.receivePaused) else { return }
pauseState.remove(.receivePaused)
pauseState.setState(on: self)
@@ -331,7 +329,6 @@
///
/// - SeeAlso: https://curl.haxx.se/libcurl/c/curl_easy_pause.html
func pauseSend() {
- URLSession.printDebug("[EasyHandle] pause send (\(pauseState))")
guard !pauseState.contains(.sendPaused) else { return }
pauseState.insert(.sendPaused)
pauseState.setState(on: self)
@@ -342,7 +339,6 @@
/// will be called before this method returns.
/// - SeeAlso: https://curl.haxx.se/libcurl/c/curl_easy_pause.html
func unpauseSend() {
- URLSession.printDebug("[EasyHandle] unpause send (\(pauseState))")
guard pauseState.contains(.sendPaused) else { return }
pauseState.remove(.sendPaused)
pauseState.setState(on: self)
@@ -461,19 +457,16 @@
///
/// - SeeAlso: <https://curl.haxx.se/libcurl/c/CURLOPT_WRITEFUNCTION.html>
func didReceive(data: UnsafeMutablePointer<Int8>, size: Int, nmemb: Int) -> Int {
- URLSession.printDebug("[EasyHandle] -> write callback \(size * nmemb)")
let d: Int = {
let buffer = Data(bytes: data, count: size*nmemb)
switch delegate.didReceive(data: buffer) {
case .proceed: return size * nmemb
case .abort: return 0
case .pause:
- URLSession.printDebug("[EasyHandle] pausing receive from callback (\(pauseState))")
pauseState.insert(.receivePaused)
return Int(CFURLSessionWriteFuncPause)
}
}()
- URLSession.printDebug("[EasyHandle] <- write callback \(d)")
return d
}
/// This callback function gets called by libcurl when it receives header
@@ -481,7 +474,6 @@
///
/// - SeeAlso: <https://curl.haxx.se/libcurl/c/CURLOPT_HEADERFUNCTION.html>
func didReceive(headerData data: UnsafeMutablePointer<Int8>, size: Int, nmemb: Int, fileLength: Double) -> Int {
- URLSession.printDebug("[EasyHandle] -> header callback \(size * nmemb)")
self.fileLength = Int64(fileLength)
let d: Int = {
let buffer = Data(bytes: data, count: size*nmemb)
@@ -489,12 +481,10 @@
case .proceed: return size * nmemb
case .abort: return 0
case .pause:
- URLSession.printDebug("[EasyHandle] pausing receive from callback (\(pauseState))")
pauseState.insert(.receivePaused)
return Int(CFURLSessionWriteFuncPause)
}
}()
- URLSession.printDebug("[EasyHandle] <- header callback \(d)")
return d
}
/// This callback function gets called by libcurl when it wants to send data
@@ -502,12 +492,10 @@
///
/// - SeeAlso: <https://curl.haxx.se/libcurl/c/CURLOPT_READFUNCTION.html>
func fill(writeBuffer data: UnsafeMutablePointer<Int8>, size: Int, nmemb: Int) -> Int {
- URLSession.printDebug("[EasyHandle] -> read callback \(size * nmemb)")
let d: Int = {
let buffer = UnsafeMutableBufferPointer(start: data, count: size * nmemb)
switch delegate.fill(writeBuffer: buffer) {
case .pause:
- URLSession.printDebug("[EasyHandle] pausing send from callback (\(pauseState))")
pauseState.insert(.sendPaused)
return Int(CFURLSessionReadFuncPause)
case .abort:
@@ -516,12 +504,10 @@
return length
}
}()
- URLSession.printDebug("[EasyHandle] <- read callback \(d)")
return d
}
func setSocketOptions(for fd: CInt) throws {
- URLSession.printDebug("[EasyHandle] -- socket options callback \(fd)")
//TODO: At this point we should call setsockopt(2) to set the QoS on
// the socket based on the QoS of the request.
//
@@ -539,7 +525,6 @@
}
func seekInputStream(offset: Int64, origin: CInt) -> CInt {
- URLSession.printDebug("[EasyHandle] -> seek callback \(offset) \(origin)")
let d: Int32 = {
/// libcurl should only use SEEK_SET
guard origin == SEEK_SET else { fatalError("Unexpected 'origin' in seek.") }
@@ -550,7 +535,6 @@
return CFURLSessionSeekCantSeek
}
}()
- URLSession.printDebug("[EasyHandle] <- seek callback \(d)")
return d
}
}
diff --git a/Foundation/NSURLSession/MultiHandle.swift b/Foundation/NSURLSession/MultiHandle.swift
index 3d63e71..d6bbb24 100644
--- a/Foundation/NSURLSession/MultiHandle.swift
+++ b/Foundation/NSURLSession/MultiHandle.swift
@@ -245,7 +245,7 @@
return NSURLErrorTimedOut
default:
//TODO: Need to map to one of the NSURLError... constants
- NSUnimplemented()
+ return NSURLErrorUnknown
}
}
}
diff --git a/TestFoundation/TestNSURLSession.swift b/TestFoundation/TestNSURLSession.swift
index 2c7c965..e7546da 100644
--- a/TestFoundation/TestNSURLSession.swift
+++ b/TestFoundation/TestNSURLSession.swift
@@ -67,7 +67,7 @@
let result = first as? [String : Any]
expectedResult = result!["capital"] as! String
} catch { }
- XCTAssertEqual("Washington D.C.", expectedResult, "Did not receive expected value")
+ XCTAssertEqual("Washington, D.C.", expectedResult, "Did not receive expected value")
expect.fulfill()
}
task.resume()