Merge pull request #1909 from Wevah/post-body-fix
URL-encode POST body values
This commit is contained in:
commit
b6e25f2d4f
|
@ -36,8 +36,12 @@ public extension URLRequest {
|
||||||
case .readerBasic:
|
case .readerBasic:
|
||||||
setValue("application/x-www-form-urlencoded", forHTTPHeaderField: "Content-Type")
|
setValue("application/x-www-form-urlencoded", forHTTPHeaderField: "Content-Type")
|
||||||
httpMethod = "POST"
|
httpMethod = "POST"
|
||||||
let postData = "Email=\(credentials.username)&Passwd=\(credentials.secret)"
|
var postData = URLComponents()
|
||||||
httpBody = postData.data(using: String.Encoding.utf8)
|
postData.queryItems = [
|
||||||
|
URLQueryItem(name: "Email", value: credentials.username),
|
||||||
|
URLQueryItem(name: "Passwd", value: credentials.secret)
|
||||||
|
]
|
||||||
|
httpBody = postData.percentEncodedQuery?.data(using: .utf8)
|
||||||
case .readerAPIKey:
|
case .readerAPIKey:
|
||||||
let auth = "GoogleLogin auth=\(credentials.secret)"
|
let auth = "GoogleLogin auth=\(credentials.secret)"
|
||||||
setValue(auth, forHTTPHeaderField: HTTPRequestHeader.authorization)
|
setValue(auth, forHTTPHeaderField: HTTPRequestHeader.authorization)
|
||||||
|
|
Loading…
Reference in New Issue