Skip to content

Commit 23da13f

Browse files
committed
Add Subpart.data
1 parent ed7100a commit 23da13f

3 files changed

Lines changed: 5 additions & 4 deletions

File tree

Sources/MultipartFormData/MultipartFormData.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ extension MultipartFormData {
116116
/// This combines all the data from the subparts into one big data object.
117117
public var httpBody: Data {
118118
let bodyData: Data = body
119-
.map { ._dash + boundary._asciiData + ._crlf + $0._data + ._crlf }
119+
.map { ._dash + boundary._asciiData + ._crlf + $0.data + ._crlf }
120120
.reduce(Data(), +)
121121
return bodyData + ._dash + boundary._asciiData + ._dash + ._crlf
122122
}

Sources/MultipartFormData/Subpart.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,15 @@ extension Subpart {
8080

8181
extension Subpart: CustomDebugStringConvertible {
8282
public var debugDescription: String {
83-
return String(bytes: _data, encoding: .utf8) ?? ""
83+
return String(bytes: data, encoding: .utf8) ?? ""
8484
}
8585
}
8686

8787
// MARK: - Helpers
8888

8989
extension Subpart {
90-
internal var _data: Data {
90+
/// The data representation of a subpart.
91+
public var data: Data {
9192
let contentTypeData: Data = contentType.map { $0.data + ._crlf } ?? Data()
9293
return contentDisposition.data + ._crlf + contentTypeData + ._crlf + body
9394
}

Tests/MultipartFormDataTests/SubpartTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ final class SubpartTests: XCTestCase {
2121
"",
2222
"a",
2323
].joined(separator: "\r\n").utf8)
24-
XCTAssertEqual(subpart._data, expectedData)
24+
XCTAssertEqual(subpart.data, expectedData)
2525
}
2626

2727
func testDebugDescription() {

0 commit comments

Comments
 (0)