2019-01-05 17:37:34 +00:00
|
|
|
//
|
2019-01-06 21:01:08 +00:00
|
|
|
// URLSessionConfiguration+Test.swift
|
2019-01-05 17:37:34 +00:00
|
|
|
// MasKitTests
|
|
|
|
//
|
|
|
|
// Created by Ben Chatelain on 1/5/19.
|
|
|
|
// Copyright © 2019 mas-cli. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
import Foundation
|
|
|
|
|
|
|
|
/// Configuration for network requests initiated from tests.
|
|
|
|
extension URLSessionConfiguration {
|
|
|
|
/// Just like defaultSessionConfiguration, returns a
|
|
|
|
/// newly created session configuration object, customised
|
|
|
|
/// from the default to your requirements.
|
|
|
|
class func testSessionConfiguration() -> URLSessionConfiguration {
|
2019-01-30 06:15:24 +00:00
|
|
|
let config = `default`
|
2019-01-05 17:37:34 +00:00
|
|
|
|
|
|
|
// Eg we think 60s is too long a timeout time.
|
|
|
|
config.timeoutIntervalForRequest = 20
|
|
|
|
|
|
|
|
// Some headers that are common to all reqeuests.
|
|
|
|
// Eg my backend needs to be explicitly asked for JSON.
|
|
|
|
config.httpAdditionalHeaders = ["MyResponseType": "JSON"]
|
|
|
|
|
|
|
|
// Eg we want to use pipelining.
|
|
|
|
config.httpShouldUsePipelining = true
|
|
|
|
|
|
|
|
return config
|
|
|
|
}
|
|
|
|
}
|