AliSoftware / AliSoftware/OHHTTPStubs
Subs are not getting Alamofire 5 parameters
- Vorherrschende Sprache
- Objective-C
- Sterne
- 5.1k
- Forks
- 597
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
### New Issue Checklist
- [X] I have tried with the latest version of OHHTTPStubs
- [X] I have read the [README](https://github.com/AliSoftware/OHHTTPStubs/blob/master/README.md)
- [X] I have read the [Using the right Swift Version of `OHHTTPStubs` for your project](https://github.com/AliSoftware/OHHTTPStubs#using-the-right-swift-version-of-ohhttpstubs-for-your-project) section
- [X] I have searched in the [existing issues](https://github.com/AliSoftware/OHHTTPStubs/issues?utf8=✓&q=is%3Aissue)
- [X] I have read [the OHHTTPStubs wiki](https://github.com/AliSoftware/OHHTTPStubs/wiki) to see if there wasn't a detailed page talking about my issue
### Environment
- version of OHHTTPStubs: 9.0.0
- integration method you are using:
* [X] Cocoapods
* [ ] Carthage
* [ ] submodule
* [ ] other
- version of the tool you use: 1.8.4
### Issue Description
I am trying to use it in a project with Alamofire 5.0.5 and for some reason, it is not getting the parameters. I just tried the sample they use on their guide:
```swift
stub(condition: isMethodPOST() && isPath("/post")) { request in
print("Method:", request.httpMethod ?? "-")
print("Request:", request)
print("Body:", request.httpBody ?? "-")
return HTTPStubsResponse(jsonObject: ["result": true], statusCode: 200, headers: nil)
}
struct Login: Encodable {
let email: String
let password: String
}
let login = Login(email: "test@test.test", password: "testPassword")
AF.request("https://httpbin.org/post",
method: .post,
parameters: login,
encoder: JSONParameterEncoder.default).validate().responseString { response in
print("response", response)
}
```
##### Complete output when you encounter the issue (if any)
```
Method: POST
Request: https://httpbin.org/post
Body: -
response success("{\"result\":true}")
```
When using a breakpoint and PO the request, this is what I get:
```
▿ https://httpbin.org/post
▿ url : Optional
▿ some : https://httpbin.org/post
- _url : https://httpbin.org/post
- cachePolicy : 0
- timeoutInterval : 60.0
- mainDocumentURL : nil
- networkServiceType : __C.NSURLRequestNetworkServiceType
- allowsCellularAccess : true
▿ httpMethod : Optional
- some : "POST"
▿ allHTTPHeaderFields : Optional>
▿ some : 5 elements
▿ 0 : 2 elements
- key : "Accept-Language"
- value : "en;q=1.0"
▿ 1 : 2 elements
- key : "Content-Type"
- value : "application/json"
▿ 2 : 2 elements
- key : "Content-Length"
- value : "52"
▿ 3 : 2 elements
- key : "User-Agent"
- value : "dummy/1.0 (dummy; build:1; iOS 13.3.0) Alamofire/5.0.5"
▿ 4 : 2 elements
- key : "Accept-Encoding"
- value : "br;q=1.0, gzip;q=0.9, deflate;q=0.8"
- httpBody : nil
▿ httpBodyStream : Optional
- some : <__NSCFInputStream: 0x6000037d6ac0>
- httpShouldHandleCookies : true
- httpShouldUsePipelining : false
```
If I remove the stub, it works perfectly with the real server:
```
response success("{\n \"args\": {}, \n \"data\": \"{\\\"email\\\":\\\"test@test.test\\\",\\\"password\\\":\\\"testPassword\\\"}\", \n \"files\": {}, \n \"form\": {}, \n \"headers\": {\n \"Accept\": \"*/*\", \n \"Accept-Encoding\": \"br;q=1.0, gzip;q=0.9, deflate;q=0.8\", \n \"Accept-Language\": \"en;q=1.0\", \n \"Content-Length\": \"52\", \n \"Content-Type\": \"application/json\", \n \"Host\": \"httpbin.org\", \n \"X-Amzn-Trace-Id\": \"Root=1-5e7d1048-dd2e0ff448f3900c34e0ec90\"\n }, \n \"json\": {\n \"email\": \"test@test.test\", \n \"password\": \"testPassword\"\n }, \n \"origin\": \"187.39.113.117\", \n \"url\": \"https://httpbin.org/post\"\n}\n")
```
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Bewertung
Dieses Issue wurde noch nicht bewertet.