提交 bab103ae 编写于 作者: C Christian Noon

Replaced force unwraps with initial guard statement in parameter encoding.

上级 61d6ddf9
......@@ -73,7 +73,7 @@ public enum ParameterEncoding {
{
var mutableURLRequest = URLRequest.URLRequest
if parameters == nil {
guard let parameters = parameters else {
return (mutableURLRequest, nil)
}
......@@ -102,7 +102,7 @@ public enum ParameterEncoding {
if let method = Method(rawValue: mutableURLRequest.HTTPMethod) where encodesParametersInURL(method) {
if let URLComponents = NSURLComponents(URL: mutableURLRequest.URL!, resolvingAgainstBaseURL: false) {
let percentEncodedQuery = (URLComponents.percentEncodedQuery.map { $0 + "&" } ?? "") + query(parameters!)
let percentEncodedQuery = (URLComponents.percentEncodedQuery.map { $0 + "&" } ?? "") + query(parameters)
URLComponents.percentEncodedQuery = percentEncodedQuery
mutableURLRequest.URL = URLComponents.URL
}
......@@ -111,7 +111,7 @@ public enum ParameterEncoding {
mutableURLRequest.setValue("application/x-www-form-urlencoded", forHTTPHeaderField: "Content-Type")
}
mutableURLRequest.HTTPBody = query(parameters!).dataUsingEncoding(
mutableURLRequest.HTTPBody = query(parameters).dataUsingEncoding(
NSUTF8StringEncoding,
allowLossyConversion: false
)
......@@ -119,7 +119,7 @@ public enum ParameterEncoding {
case .JSON:
do {
let options = NSJSONWritingOptions()
let data = try NSJSONSerialization.dataWithJSONObject(parameters!, options: options)
let data = try NSJSONSerialization.dataWithJSONObject(parameters, options: options)
mutableURLRequest.setValue("application/json", forHTTPHeaderField: "Content-Type")
mutableURLRequest.HTTPBody = data
......@@ -129,7 +129,7 @@ public enum ParameterEncoding {
case .PropertyList(let format, let options):
do {
let data = try NSPropertyListSerialization.dataWithPropertyList(
parameters!,
parameters,
format: format,
options: options
)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册