Skip to content

Fix for SR-2913 - HTTP headers not picked up #681

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 10, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions Foundation/NSURLSession/NSURLSessionTask.swift
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ open class URLSessionTask : NSObject, NSCopying {
originalRequest = nil
body = .none
workQueue = DispatchQueue(label: "URLSessionTask.notused.0")
taskAttributesIsolation = DispatchQueue(label: "URLSessionTask.notused.1")
taskAttributesIsolation = DispatchQueue(label: "URLSessionTask.notused.1", attributes: DispatchQueue.Attributes.concurrent)
let fileName = NSTemporaryDirectory() + NSUUID().uuidString + ".tmp"
_ = FileManager.default.createFile(atPath: fileName, contents: nil)
self.tempFileURL = URL(fileURLWithPath: fileName)
Expand Down Expand Up @@ -145,7 +145,7 @@ open class URLSessionTask : NSObject, NSCopying {
return r
}
//TODO: dispatch_barrier_async
set { taskAttributesIsolation.async { self._currentRequest = newValue } }
set { taskAttributesIsolation.async(flags: .barrier) { self._currentRequest = newValue } }
}
fileprivate var _currentRequest: URLRequest? = nil
/*@NSCopying*/ open fileprivate(set) var response: URLResponse? {
Expand All @@ -154,7 +154,7 @@ open class URLSessionTask : NSObject, NSCopying {
taskAttributesIsolation.sync { r = self._response }
return r
}
set { taskAttributesIsolation.async { self._response = newValue } }
set { taskAttributesIsolation.async(flags: .barrier) { self._response = newValue } }
}
fileprivate var _response: URLResponse? = nil

Expand All @@ -170,7 +170,7 @@ open class URLSessionTask : NSObject, NSCopying {
taskAttributesIsolation.sync { r = self._countOfBytesReceived }
return r
}
set { taskAttributesIsolation.async { self._countOfBytesReceived = newValue } }
set { taskAttributesIsolation.async(flags: .barrier) { self._countOfBytesReceived = newValue } }
}
fileprivate var _countOfBytesReceived: Int64 = 0

Expand All @@ -181,7 +181,7 @@ open class URLSessionTask : NSObject, NSCopying {
taskAttributesIsolation.sync { r = self._countOfBytesSent }
return r
}
set { taskAttributesIsolation.async { self._countOfBytesSent = newValue } }
set { taskAttributesIsolation.async(flags: .barrier) { self._countOfBytesSent = newValue } }
}

fileprivate var _countOfBytesSent: Int64 = 0
Expand Down Expand Up @@ -213,7 +213,7 @@ open class URLSessionTask : NSObject, NSCopying {
taskAttributesIsolation.sync { r = self._state }
return r
}
set { taskAttributesIsolation.async { self._state = newValue } }
set { taskAttributesIsolation.async(flags: .barrier) { self._state = newValue } }
}
fileprivate var _state: URLSessionTask.State = .suspended

Expand Down Expand Up @@ -298,7 +298,7 @@ open class URLSessionTask : NSObject, NSCopying {
return r
}
set {
taskAttributesIsolation.async { self._priority = newValue }
taskAttributesIsolation.async(flags: .barrier) { self._priority = newValue }
}
}
fileprivate var _priority: Float = URLSessionTaskPriorityDefault
Expand Down Expand Up @@ -791,7 +791,7 @@ extension URLSessionTask: _EasyHandleDelegate {
// to the delegate. But in case of redirects etc. we might send another
// request.
guard case .transferInProgress(let ts) = internalState else { fatalError("Transfer completed, but it wasn't in progress.") }
guard let request = currentRequest else { fatalError("Transfer completed, but there's no currect request.") }
guard let request = currentRequest else { fatalError("Transfer completed, but there's no current request.") }
guard errorCode == nil else {
internalState = .transferFailed
failWith(errorCode: errorCode!, request: request)
Expand Down