Skip to content

Commit 12c8461

Browse files
Pushkar N Kulkarniparkera
Pushkar N Kulkarni
authored andcommitted
PR 426 - Fixing a test and removing debug prints (#590)
1 parent af4ecf3 commit 12c8461

File tree

3 files changed

+2
-18
lines changed

3 files changed

+2
-18
lines changed

Foundation/NSURLSession/EasyHandle.swift

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,6 @@ extension _EasyHandle {
311311
///
312312
/// - SeeAlso: https://curl.haxx.se/libcurl/c/curl_easy_pause.html
313313
func pauseReceive() {
314-
URLSession.printDebug("[EasyHandle] pause receive (\(pauseState))")
315314
guard !pauseState.contains(.receivePaused) else { return }
316315
pauseState.insert(.receivePaused)
317316
pauseState.setState(on: self)
@@ -322,7 +321,6 @@ extension _EasyHandle {
322321
/// will be called before this method returns.
323322
/// - SeeAlso: https://curl.haxx.se/libcurl/c/curl_easy_pause.html
324323
func unpauseReceive() {
325-
URLSession.printDebug("[EasyHandle] unpause receive (\(pauseState))")
326324
guard pauseState.contains(.receivePaused) else { return }
327325
pauseState.remove(.receivePaused)
328326
pauseState.setState(on: self)
@@ -331,7 +329,6 @@ extension _EasyHandle {
331329
///
332330
/// - SeeAlso: https://curl.haxx.se/libcurl/c/curl_easy_pause.html
333331
func pauseSend() {
334-
URLSession.printDebug("[EasyHandle] pause send (\(pauseState))")
335332
guard !pauseState.contains(.sendPaused) else { return }
336333
pauseState.insert(.sendPaused)
337334
pauseState.setState(on: self)
@@ -342,7 +339,6 @@ extension _EasyHandle {
342339
/// will be called before this method returns.
343340
/// - SeeAlso: https://curl.haxx.se/libcurl/c/curl_easy_pause.html
344341
func unpauseSend() {
345-
URLSession.printDebug("[EasyHandle] unpause send (\(pauseState))")
346342
guard pauseState.contains(.sendPaused) else { return }
347343
pauseState.remove(.sendPaused)
348344
pauseState.setState(on: self)
@@ -461,53 +457,45 @@ fileprivate extension _EasyHandle {
461457
///
462458
/// - SeeAlso: <https://curl.haxx.se/libcurl/c/CURLOPT_WRITEFUNCTION.html>
463459
func didReceive(data: UnsafeMutablePointer<Int8>, size: Int, nmemb: Int) -> Int {
464-
URLSession.printDebug("[EasyHandle] -> write callback \(size * nmemb)")
465460
let d: Int = {
466461
let buffer = Data(bytes: data, count: size*nmemb)
467462
switch delegate.didReceive(data: buffer) {
468463
case .proceed: return size * nmemb
469464
case .abort: return 0
470465
case .pause:
471-
URLSession.printDebug("[EasyHandle] pausing receive from callback (\(pauseState))")
472466
pauseState.insert(.receivePaused)
473467
return Int(CFURLSessionWriteFuncPause)
474468
}
475469
}()
476-
URLSession.printDebug("[EasyHandle] <- write callback \(d)")
477470
return d
478471
}
479472
/// This callback function gets called by libcurl when it receives header
480473
/// data.
481474
///
482475
/// - SeeAlso: <https://curl.haxx.se/libcurl/c/CURLOPT_HEADERFUNCTION.html>
483476
func didReceive(headerData data: UnsafeMutablePointer<Int8>, size: Int, nmemb: Int, fileLength: Double) -> Int {
484-
URLSession.printDebug("[EasyHandle] -> header callback \(size * nmemb)")
485477
self.fileLength = Int64(fileLength)
486478
let d: Int = {
487479
let buffer = Data(bytes: data, count: size*nmemb)
488480
switch delegate.didReceive(headerData: buffer) {
489481
case .proceed: return size * nmemb
490482
case .abort: return 0
491483
case .pause:
492-
URLSession.printDebug("[EasyHandle] pausing receive from callback (\(pauseState))")
493484
pauseState.insert(.receivePaused)
494485
return Int(CFURLSessionWriteFuncPause)
495486
}
496487
}()
497-
URLSession.printDebug("[EasyHandle] <- header callback \(d)")
498488
return d
499489
}
500490
/// This callback function gets called by libcurl when it wants to send data
501491
/// it to the network.
502492
///
503493
/// - SeeAlso: <https://curl.haxx.se/libcurl/c/CURLOPT_READFUNCTION.html>
504494
func fill(writeBuffer data: UnsafeMutablePointer<Int8>, size: Int, nmemb: Int) -> Int {
505-
URLSession.printDebug("[EasyHandle] -> read callback \(size * nmemb)")
506495
let d: Int = {
507496
let buffer = UnsafeMutableBufferPointer(start: data, count: size * nmemb)
508497
switch delegate.fill(writeBuffer: buffer) {
509498
case .pause:
510-
URLSession.printDebug("[EasyHandle] pausing send from callback (\(pauseState))")
511499
pauseState.insert(.sendPaused)
512500
return Int(CFURLSessionReadFuncPause)
513501
case .abort:
@@ -516,12 +504,10 @@ fileprivate extension _EasyHandle {
516504
return length
517505
}
518506
}()
519-
URLSession.printDebug("[EasyHandle] <- read callback \(d)")
520507
return d
521508
}
522509

523510
func setSocketOptions(for fd: CInt) throws {
524-
URLSession.printDebug("[EasyHandle] -- socket options callback \(fd)")
525511
//TODO: At this point we should call setsockopt(2) to set the QoS on
526512
// the socket based on the QoS of the request.
527513
//
@@ -539,7 +525,6 @@ fileprivate extension _EasyHandle {
539525
}
540526

541527
func seekInputStream(offset: Int64, origin: CInt) -> CInt {
542-
URLSession.printDebug("[EasyHandle] -> seek callback \(offset) \(origin)")
543528
let d: Int32 = {
544529
/// libcurl should only use SEEK_SET
545530
guard origin == SEEK_SET else { fatalError("Unexpected 'origin' in seek.") }
@@ -550,7 +535,6 @@ fileprivate extension _EasyHandle {
550535
return CFURLSessionSeekCantSeek
551536
}
552537
}()
553-
URLSession.printDebug("[EasyHandle] <- seek callback \(d)")
554538
return d
555539
}
556540
}

Foundation/NSURLSession/MultiHandle.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ fileprivate extension _EasyHandle {
245245
return NSURLErrorTimedOut
246246
default:
247247
//TODO: Need to map to one of the NSURLError... constants
248-
NSUnimplemented()
248+
return NSURLErrorUnknown
249249
}
250250
}
251251
}

TestFoundation/TestNSURLSession.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class TestURLSession : XCTestCase {
6767
let result = first as? [String : Any]
6868
expectedResult = result!["capital"] as! String
6969
} catch { }
70-
XCTAssertEqual("Washington D.C.", expectedResult, "Did not receive expected value")
70+
XCTAssertEqual("Washington, D.C.", expectedResult, "Did not receive expected value")
7171
expect.fulfill()
7272
}
7373
task.resume()

0 commit comments

Comments
 (0)