Skip to content

Commit 7243f89

Browse files
committed
Moving HTTPBodySource out of http folder and renaming to BodySource
1 parent da93c95 commit 7243f89

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
@@ -332,7 +332,7 @@
332332
B9974B981EDF4A22007F15B8 /* libcurlHelpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = B9974B911EDF4A22007F15B8 /* libcurlHelpers.swift */; };
333333
B9974B991EDF4A22007F15B8 /* HTTPURLProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = B9974B921EDF4A22007F15B8 /* HTTPURLProtocol.swift */; };
334334
B9974B9A1EDF4A22007F15B8 /* HTTPMessage.swift in Sources */ = {isa = PBXBuildFile; fileRef = B9974B931EDF4A22007F15B8 /* HTTPMessage.swift */; };
335-
B9974B9B1EDF4A22007F15B8 /* HTTPBodySource.swift in Sources */ = {isa = PBXBuildFile; fileRef = B9974B941EDF4A22007F15B8 /* HTTPBodySource.swift */; };
335+
B9974B9B1EDF4A22007F15B8 /* BodySource.swift in Sources */ = {isa = PBXBuildFile; fileRef = B9974B941EDF4A22007F15B8 /* BodySource.swift */; };
336336
B9974B9C1EDF4A22007F15B8 /* EasyHandle.swift in Sources */ = {isa = PBXBuildFile; fileRef = B9974B951EDF4A22007F15B8 /* EasyHandle.swift */; };
337337
BD8042161E09857800487EB8 /* TestLengthFormatter.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD8042151E09857800487EB8 /* TestLengthFormatter.swift */; };
338338
BDBB65901E256BFA001A7286 /* TestEnergyFormatter.swift in Sources */ = {isa = PBXBuildFile; fileRef = BDBB658F1E256BFA001A7286 /* TestEnergyFormatter.swift */; };
@@ -803,7 +803,7 @@
803803
B9974B911EDF4A22007F15B8 /* libcurlHelpers.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = libcurlHelpers.swift; sourceTree = "<group>"; };
804804
B9974B921EDF4A22007F15B8 /* HTTPURLProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = HTTPURLProtocol.swift; path = http/HTTPURLProtocol.swift; sourceTree = "<group>"; };
805805
B9974B931EDF4A22007F15B8 /* HTTPMessage.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = HTTPMessage.swift; path = http/HTTPMessage.swift; sourceTree = "<group>"; };
806-
B9974B941EDF4A22007F15B8 /* HTTPBodySource.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = HTTPBodySource.swift; path = http/HTTPBodySource.swift; sourceTree = "<group>"; };
806+
B9974B941EDF4A22007F15B8 /* BodySource.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BodySource.swift; sourceTree = "<group>"; };
807807
B9974B951EDF4A22007F15B8 /* EasyHandle.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EasyHandle.swift; sourceTree = "<group>"; };
808808
BD8042151E09857800487EB8 /* TestLengthFormatter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestLengthFormatter.swift; sourceTree = "<group>"; };
809809
BDBB658F1E256BFA001A7286 /* TestEnergyFormatter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestEnergyFormatter.swift; sourceTree = "<group>"; };
@@ -998,6 +998,7 @@
998998
614732781FC2DEB7005B5E61 /* libcurl */,
999999
E4F889331E9CF04D008A70EB /* http */,
10001000
5B1FD9C81D6D16580080E83C /* Configuration.swift */,
1001+
B9974B941EDF4A22007F15B8 /* BodySource.swift */,
10011002
5B1FD9CE1D6D16580080E83C /* URLSession.swift */,
10021003
5B1FD9CF1D6D16580080E83C /* URLSessionConfiguration.swift */,
10031004
5B1FD9D01D6D16580080E83C /* URLSessionDelegate.swift */,
@@ -1381,7 +1382,6 @@
13811382
B9974B921EDF4A22007F15B8 /* HTTPURLProtocol.swift */,
13821383
B9974B8F1EDF4A22007F15B8 /* TransferState.swift */,
13831384
B9974B931EDF4A22007F15B8 /* HTTPMessage.swift */,
1384-
B9974B941EDF4A22007F15B8 /* HTTPBodySource.swift */,
13851385
);
13861386
name = http;
13871387
sourceTree = "<group>";
@@ -2236,7 +2236,7 @@
22362236
EADE0BB81BD15E0000C49C64 /* Process.swift in Sources */,
22372237
5BF7AEB31BCD51F9008F214A /* NSObjCRuntime.swift in Sources */,
22382238
5BD31D3F1D5D19D600563814 /* Dictionary.swift in Sources */,
2239-
B9974B9B1EDF4A22007F15B8 /* HTTPBodySource.swift in Sources */,
2239+
B9974B9B1EDF4A22007F15B8 /* BodySource.swift in Sources */,
22402240
5B94E8821C430DE70055C035 /* NSStringAPI.swift in Sources */,
22412241
5B0163BB1D024EB7003CCD96 /* DateComponents.swift in Sources */,
22422242
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
@@ -425,7 +425,7 @@
425425
'Foundation/URLResponse.swift',
426426
'Foundation/URLSession/Configuration.swift',
427427
'Foundation/URLSession/libcurl/EasyHandle.swift',
428-
'Foundation/URLSession/http/HTTPBodySource.swift',
428+
'Foundation/URLSession/BodySource.swift',
429429
'Foundation/URLSession/http/HTTPMessage.swift',
430430
'Foundation/URLSession/libcurl/MultiHandle.swift',
431431
'Foundation/URLSession/URLSession.swift',

0 commit comments

Comments
 (0)