Skip to content

Commit

Permalink
change to using HTTPURLResponse
Browse files Browse the repository at this point in the history
  • Loading branch information
Machx committed Oct 13, 2020
1 parent a96b132 commit 75a89fe
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions Sources/MockNetworking/MockURLProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,24 @@ import Foundation
public final class MockPropertyResponse {
typealias HTTPStatusCode = Int // Because Apple uses Int

var statusCode: HTTPStatusCode
var response: HTTPURLResponse?
var body: Data?
var error: Error?
var httpVersion: String = HTTPURLResponse.HTTP_1_1
var headerFields = [String: String]()
var bodyData: Data?
var error: Error?

init(status: HTTPStatusCode = 200,
init(url: URL,
status: HTTPStatusCode = 200,
httpVersion version: String = HTTPURLResponse.HTTP_1_1,
headerFields headers: [String: String],
body: Data?,
error requestError: Error?) {
statusCode = status

response = HTTPURLResponse(url: url,
statusCode: status,
httpVersion: version,
headerFields: headers)
httpVersion = version
headerFields = headers
bodyData = body
error = requestError
}
Expand Down

0 comments on commit 75a89fe

Please sign in to comment.