Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to identify if a request type is synchronous or asynchronous

Actually, my requirement is, client can call my rest based services in both synchronous (request-response) or in asynchronous (request-acknowledgment-response) mode. Now, based on the request type, I have to follow the mode.

Now, my question is, is there any way, from the request itself, by default, is there any indicator, which will tells the clients desire request-response model. Service protocol is http.

if not possible, then what will be the best practice, to handle this type of scenario.

like image 345
anij Avatar asked Nov 01 '22 13:11

anij


1 Answers

You can have the client specify its preference to receive an asynchronous response via a header:

Prefer: respond-async

You can find details here: https://www.rfc-editor.org/rfc/rfc7240#section-4.1. I am not aware of any way to explicitly request the opposite, a synchronous response.

like image 54
Simon Fischer Avatar answered Nov 09 '22 22:11

Simon Fischer