Skip to content

Commit b21a90f

Browse files
authored
Merge pull request #1336 from saiHemak/bodysource
2 parents 44eece9 + 7243f89 commit b21a90f

File tree

5 files changed

+23
-23
lines changed

5 files changed

+23
-23
lines changed

Foundation.xcodeproj/project.pbxproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@
338338
B9974B981EDF4A22007F15B8 /* libcurlHelpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = B9974B911EDF4A22007F15B8 /* libcurlHelpers.swift */; };
339339
B9974B991EDF4A22007F15B8 /* HTTPURLProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = B9974B921EDF4A22007F15B8 /* HTTPURLProtocol.swift */; };
340340
B9974B9A1EDF4A22007F15B8 /* HTTPMessage.swift in Sources */ = {isa = PBXBuildFile; fileRef = B9974B931EDF4A22007F15B8 /* HTTPMessage.swift */; };
341-
B9974B9B1EDF4A22007F15B8 /* HTTPBodySource.swift in Sources */ = {isa = PBXBuildFile; fileRef = B9974B941EDF4A22007F15B8 /* HTTPBodySource.swift */; };
341+
B9974B9B1EDF4A22007F15B8 /* BodySource.swift in Sources */ = {isa = PBXBuildFile; fileRef = B9974B941EDF4A22007F15B8 /* BodySource.swift */; };
342342
B9974B9C1EDF4A22007F15B8 /* EasyHandle.swift in Sources */ = {isa = PBXBuildFile; fileRef = B9974B951EDF4A22007F15B8 /* EasyHandle.swift */; };
343343
BD8042161E09857800487EB8 /* TestLengthFormatter.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD8042151E09857800487EB8 /* TestLengthFormatter.swift */; };
344344
BDBB65901E256BFA001A7286 /* TestEnergyFormatter.swift in Sources */ = {isa = PBXBuildFile; fileRef = BDBB658F1E256BFA001A7286 /* TestEnergyFormatter.swift */; };
@@ -815,7 +815,7 @@
815815
B9974B911EDF4A22007F15B8 /* libcurlHelpers.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = libcurlHelpers.swift; sourceTree = "<group>"; };
816816
B9974B921EDF4A22007F15B8 /* HTTPURLProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = HTTPURLProtocol.swift; path = http/HTTPURLProtocol.swift; sourceTree = "<group>"; };
817817
B9974B931EDF4A22007F15B8 /* HTTPMessage.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = HTTPMessage.swift; path = http/HTTPMessage.swift; sourceTree = "<group>"; };
818-
B9974B941EDF4A22007F15B8 /* HTTPBodySource.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = HTTPBodySource.swift; path = http/HTTPBodySource.swift; sourceTree = "<group>"; };
818+
B9974B941EDF4A22007F15B8 /* BodySource.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BodySource.swift; sourceTree = "<group>"; };
819819
B9974B951EDF4A22007F15B8 /* EasyHandle.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EasyHandle.swift; sourceTree = "<group>"; };
820820
BD8042151E09857800487EB8 /* TestLengthFormatter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestLengthFormatter.swift; sourceTree = "<group>"; };
821821
BDBB658F1E256BFA001A7286 /* TestEnergyFormatter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestEnergyFormatter.swift; sourceTree = "<group>"; };
@@ -1010,6 +1010,7 @@
10101010
614732781FC2DEB7005B5E61 /* libcurl */,
10111011
E4F889331E9CF04D008A70EB /* http */,
10121012
5B1FD9C81D6D16580080E83C /* Configuration.swift */,
1013+
B9974B941EDF4A22007F15B8 /* BodySource.swift */,
10131014
5B1FD9CE1D6D16580080E83C /* URLSession.swift */,
10141015
5B1FD9CF1D6D16580080E83C /* URLSessionConfiguration.swift */,
10151016
5B1FD9D01D6D16580080E83C /* URLSessionDelegate.swift */,
@@ -1399,7 +1400,6 @@
13991400
B9974B921EDF4A22007F15B8 /* HTTPURLProtocol.swift */,
14001401
B9974B8F1EDF4A22007F15B8 /* TransferState.swift */,
14011402
B9974B931EDF4A22007F15B8 /* HTTPMessage.swift */,
1402-
B9974B941EDF4A22007F15B8 /* HTTPBodySource.swift */,
14031403
);
14041404
name = http;
14051405
sourceTree = "<group>";
@@ -2255,7 +2255,7 @@
22552255
EADE0BB81BD15E0000C49C64 /* Process.swift in Sources */,
22562256
5BF7AEB31BCD51F9008F214A /* NSObjCRuntime.swift in Sources */,
22572257
5BD31D3F1D5D19D600563814 /* Dictionary.swift in Sources */,
2258-
B9974B9B1EDF4A22007F15B8 /* HTTPBodySource.swift in Sources */,
2258+
B9974B9B1EDF4A22007F15B8 /* BodySource.swift in Sources */,
22592259
5B94E8821C430DE70055C035 /* NSStringAPI.swift in Sources */,
22602260
5B0163BB1D024EB7003CCD96 /* DateComponents.swift in Sources */,
22612261
5BF7AEAB1BCD51F9008F214A /* NSDictionary.swift in Sources */,

Foundation/URLSession/http/HTTPBodySource.swift renamed to Foundation/URLSession/BodySource.swift

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Foundation/URLSession/HTTPBodySource.swift - URLSession & libcurl
1+
// Foundation/URLSession/BodySource.swift - URLSession & libcurl
22
//
33
// This source file is part of the Swift.org open source project
44
//
@@ -39,16 +39,16 @@ internal func splitData(dispatchData data: DispatchData, atPosition position: In
3939
return (data.subdata(in: 0..<position), data.subdata(in: position..<data.count))
4040
}
4141

42-
/// A (non-blocking) source for HTTP body data.
43-
internal protocol _HTTPBodySource: class {
42+
/// A (non-blocking) source for body data.
43+
internal protocol _BodySource: class {
4444
/// Get the next chunck of data.
4545
///
4646
/// - Returns: `.data` until the source is exhausted, at which point it will
4747
/// return `.done`. Since this is non-blocking, it will return `.retryLater`
4848
/// if no data is available at this point, but will be available later.
49-
func getNextChunk(withLength length: Int) -> _HTTPBodySourceDataChunk
49+
func getNextChunk(withLength length: Int) -> _BodySourceDataChunk
5050
}
51-
internal enum _HTTPBodySourceDataChunk {
51+
internal enum _BodySourceDataChunk {
5252
case data(DispatchData)
5353
/// The source is depleted.
5454
case done
@@ -57,20 +57,20 @@ internal enum _HTTPBodySourceDataChunk {
5757
case error
5858
}
5959

60-
/// A HTTP body data source backed by `DispatchData`.
61-
internal final class _HTTPBodyDataSource {
60+
/// A body data source backed by `DispatchData`.
61+
internal final class _BodyDataSource {
6262
var data: DispatchData!
6363
init(data: DispatchData) {
6464
self.data = data
6565
}
6666
}
6767

68-
extension _HTTPBodyDataSource : _HTTPBodySource {
68+
extension _BodyDataSource : _BodySource {
6969
enum _Error : Error {
7070
case unableToRewindData
7171
}
7272

73-
func getNextChunk(withLength length: Int) -> _HTTPBodySourceDataChunk {
73+
func getNextChunk(withLength length: Int) -> _BodySourceDataChunk {
7474
let remaining = data.count
7575
if remaining == 0 {
7676
return .done
@@ -98,7 +98,7 @@ extension _HTTPBodyDataSource : _HTTPBodySource {
9898
/// - Note: Calls to `getNextChunk(withLength:)` and callbacks from libdispatch
9999
/// should all happen on the same (serial) queue, and hence this code doesn't
100100
/// have to be thread safe.
101-
internal final class _HTTPBodyFileSource {
101+
internal final class _BodyFileSource {
102102
fileprivate let fileURL: URL
103103
fileprivate let channel: DispatchIO
104104
fileprivate let workQueue: DispatchQueue
@@ -146,7 +146,7 @@ internal final class _HTTPBodyFileSource {
146146
}
147147
}
148148

149-
fileprivate extension _HTTPBodyFileSource {
149+
fileprivate extension _BodyFileSource {
150150
fileprivate var desiredBufferLength: Int { return 3 * CFURLSessionMaxWriteSize }
151151
/// Enqueue a dispatch I/O read to fill the buffer.
152152
///
@@ -208,8 +208,8 @@ fileprivate extension _HTTPBodyFileSource {
208208
}
209209
}
210210

211-
extension _HTTPBodyFileSource : _HTTPBodySource {
212-
func getNextChunk(withLength length: Int) -> _HTTPBodySourceDataChunk {
211+
extension _BodyFileSource : _BodySource {
212+
func getNextChunk(withLength length: Int) -> _BodySourceDataChunk {
213213
switch availableChunk {
214214
case .empty:
215215
readNextChunk()

Foundation/URLSession/http/HTTPURLProtocol.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -424,10 +424,10 @@ extension _HTTPURLProtocol {
424424
case .none:
425425
return _HTTPTransferState(url: url, bodyDataDrain: drain)
426426
case .data(let data):
427-
let source = _HTTPBodyDataSource(data: data)
427+
let source = _BodyDataSource(data: data)
428428
return _HTTPTransferState(url: url, bodyDataDrain: drain, bodySource: source)
429429
case .file(let fileURL):
430-
let source = _HTTPBodyFileSource(fileURL: fileURL, workQueue: workQueue, dataAvailableHandler: { [weak self] in
430+
let source = _BodyFileSource(fileURL: fileURL, workQueue: workQueue, dataAvailableHandler: { [weak self] in
431431
// Unpause the easy handle
432432
self?.easyHandle.unpauseSend()
433433
})

Foundation/URLSession/http/TransferState.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ extension _HTTPURLProtocol {
3939
/// Once the headers is complete, this will contain the response
4040
var response: HTTPURLResponse?
4141
/// The body data to be sent in the request
42-
let requestBodySource: _HTTPBodySource?
42+
let requestBodySource: _BodySource?
4343
/// Body data received
4444
let bodyDataDrain: _DataDrain
4545
/// Describes what to do with received body data for this transfer:
@@ -67,7 +67,7 @@ extension _HTTPURLProtocol._HTTPTransferState {
6767
self.bodyDataDrain = bodyDataDrain
6868
}
6969
/// Transfer state that sends body data and can receive body data.
70-
init(url: URL, bodyDataDrain: _HTTPURLProtocol._DataDrain, bodySource: _HTTPBodySource) {
70+
init(url: URL, bodyDataDrain: _HTTPURLProtocol._DataDrain, bodySource: _BodySource) {
7171
self.url = url
7272
self.parsedResponseHeader = _HTTPURLProtocol._ParsedResponseHeader()
7373
self.response = nil
@@ -131,7 +131,7 @@ extension _HTTPURLProtocol._HTTPTransferState {
131131
///
132132
/// This can be used to either set the initial body source, or to reset it
133133
/// e.g. when restarting a transfer.
134-
func bySetting(bodySource newSource: _HTTPBodySource) -> _HTTPURLProtocol._HTTPTransferState {
134+
func bySetting(bodySource newSource: _BodySource) -> _HTTPURLProtocol._HTTPTransferState {
135135
return _HTTPURLProtocol._HTTPTransferState(url: url, parsedResponseHeader: parsedResponseHeader, response: response, requestBodySource: newSource, bodyDataDrain: bodyDataDrain)
136136
}
137137
}

build.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@
430430
'Foundation/URLResponse.swift',
431431
'Foundation/URLSession/Configuration.swift',
432432
'Foundation/URLSession/libcurl/EasyHandle.swift',
433-
'Foundation/URLSession/http/HTTPBodySource.swift',
433+
'Foundation/URLSession/BodySource.swift',
434434
'Foundation/URLSession/http/HTTPMessage.swift',
435435
'Foundation/URLSession/libcurl/MultiHandle.swift',
436436
'Foundation/URLSession/URLSession.swift',

0 commit comments

Comments
 (0)