I have this problem: when I request arguments in URL, such as: http://www.xxxx.com/app/MobileService?action=xxxx. when the request is sent, the URL in the ? is turned into %3F by the url(for target: Target) -> URL method, causing the request to fail.
the method:
```swift
private final class func url(for target: Target) -> URL {
if target.path.isEmpty {
return target.baseURL
}
return target.baseURL.appendingPathComponent(target.path)
}
``
The parameters in the url are added to the[String: Any]` dictionary, and the work is normal
I have the same question 锛宧ave you fix it ?
you can set a good success:
// MARK: - Set the request to the head
let myEndpointClosure = { (target: RequestAPI) -> Endpoint<RequestAPI> in
print("baseURL:\(target.baseURL)\n path:\(target.path)")
let url = target.baseURL.absoluteString + target.path
print("url:\(url)")
//http://XXXX/api/xlogin.ashx?action=xulogin
//This method will escape special characters
//let url = target.baseURL.appendingPathComponent(target.path).absoluteString
//http://XXXX/api/xlogin.ashx%3Faction=xulogin
let endpoint = Endpoint<RequestAPI>(
url: url,
sampleResponseClosure: { .networkResponse(200, target.sampleData) },
method: target.method,
parameters: target.parameters,
parameterEncoding: target.parameterEncoding
)
//Set up your header information
return endpoint.adding(newHTTPHeaderFields: [:])
}
let LoginProvider = RxMoyaProvider<RequestAPI>(endpointClosure: myEndpointClosure)
public extension URL
{
...
self = URL.init(string: target.baseURL.absoluteString + target.path)!
}
This issue has been marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
This issue has been auto-closed because there hasn't been any activity for at least 21 days. However, we really appreciate your contribution, so thank you for that! 馃檹 Also, feel free to open a new issue if you still experience this problem 馃憤.
Most helpful comment
public extension URL
{
...
self = URL.init(string: target.baseURL.absoluteString + target.path)!
}