1👍
Depending on how much does it take to generate PDF, you may want to block the response until the file is generated and only then return HTTP 201.
It has no influence on multithreading, neither for the client, nor for the server:
-
The client should do non-blocking requests any way (or at least do them from a thread different than the one which handles UI events). Moreover, if the client doesn’t care about the response (i.e. whether the PDF is generated correctly or not), it’s up to the client to send the request without waiting for the response.
-
The server… well, the server has to do PDF generation anyway. Returning HTTP 201 immediately won’t change anything. Also, the fact that the server is currently responding to one request doesn’t mean it won’t process another one (unless you have too many requests or use a very weirdly configured HTTP server).
If PDF generation actually takes a long time (say more than a minute), then returning HTTP 202 Accepted (and not HTTP 201!) can be a solution in order to avoid timeouts or situations where clients won’t understand why the server is not responding for too long.