-
Notifications
You must be signed in to change notification settings - Fork 412
Async requests do not return a response map #512
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
Unfortunately there isn't a way to do out of the box because of the async nature. It would break the functional abstraction of a response/response map. The map would not have headers or body available. However, you can achieve a similiar functionality in tests by putting the async response inside a promise and then blocking in your tests until the result comes back with deref. In terms of code, it'd be something like this: (let [promise-response (promise)]
(http/get "..." {:async? true} (fn [response] (deliver promise-response response))]
(deref promise-response 1000) ; wait up to 1000ms for the response
) |
Hi Raymond, thanks for responding! The code I've shown is not the real code. In our case the async request is done inside a function which we call in our test where we can't inject a custom callback. However, our function returns whatever Wouldn't it be possible for |
That does seem like a reasonable request. I can think of two ways this could be done: Option 1: Introduce no new options and replace the current
|
Hi,
when doing an async request like:
response
isorg.apache.http.HttpResponse
and not a Ring response map.In our use case we're using the code above in our tests.
Can the return value of an async request also be wrapped in such a map?
The text was updated successfully, but these errors were encountered: