[Swift 4] Add createURLRequest method (#1727)

* add create URL Request method

* add comment
This commit is contained in:
Daiki Matsudate
2018-12-27 01:19:11 +09:00
committed by William Cheng
parent 902a4b4099
commit c2273a651a
7 changed files with 63 additions and 0 deletions

View File

@@ -64,6 +64,15 @@ open class AlamofireRequestBuilder<T>: RequestBuilder<T> {
return Alamofire.SessionManager(configuration: configuration)
}
/**
May be overridden by a subclass if you want to custom request constructor.
*/
open func createURLRequest() -> URLRequest? {
let encoding: ParameterEncoding = isBody ? JSONDataEncoding() : URLEncoding()
guard let originalRequest = try? URLRequest(url: URLString, method: HTTPMethod(rawValue: method)!, headers: buildHeaders()) else { return nil }
return try? encoding.encode(originalRequest, with: parameters)
}
/**
May be overridden by a subclass if you want to control the Content-Type
that is given to an uploaded form part.