Skip to content

Commit 79e1655

Browse files
authored
fix(request): Fixed delete request missing body (#21)
1 parent 20b9a74 commit 79e1655

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

Sources/SimpleHTTP/Request/Request.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public struct Request<Output> {
7979

8080
/// Creates a DELETE request with a Encodable body
8181
public static func delete(_ path: Path, body: Encodable, query: [String: QueryParam] = [:]) -> Self {
82-
self.init(path: path, method: .delete, query: query, body: nil)
82+
self.init(path: path, method: .delete, query: query, body: .encodable(body))
8383
}
8484

8585
/// Creates a Request.

Tests/SimpleHTTPTests/Request/RequestTests.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@ class RequestTests: XCTestCase {
8484
)
8585
}
8686

87+
func test_initDelete_withBody_returnRequestWithBody() {
88+
let request = Request<Void>.delete("", body: BodyMock())
89+
90+
XCTAssertNotNil(request.body)
91+
}
8792
}
8893

8994
private struct BodyMock: Encodable {

0 commit comments

Comments
 (0)