Rest is stateless. There should be no dependency between rest requests, and it is not necessary to call another request before calling a request. There should not be a session in rest, especially the rest request should not save the information in sesssion for use in subsequent calls. Even if security authentication is included, the client should not need to log in early and then save the permission information in the session, and the subsequent request is invoked with the same session.
The way to implement stateless is to include all information in the current request, including validation information. HTTP is stateless, HTTP has a authorization header, HTTP requirements are in each request to put the authentication information inside, the server every time before processing the request to verify the information. For security, we can provide a Rest API that generates tokens, which the client calls to generate tokens (a username/password can be attached to generate tokens). This token is placed in the authentication header in all subsequent requests.
The following code is the implementation of Qnetworkrequest plus authorization head
QString _url;//url
QString _token;//token
//
Qnetworkrequest Mreq;
Qnetworkaccessmanager *tnam = new Qnetworkaccessmanager ();
Qeventloop Loop;
Qobject::connect (Tnam, SIGNAL (Finished (qnetworkreply *)), &loop, SLOT (Quit ()));
Mreq.seturl (Qurl (_url));
Mreq.setheader (Qnetworkrequest::contenttypeheader, "application/x-www-form-urlencoded");
//
QString Token_headerdata = "token" + _token;
Mreq.setrawheader ("Authorization", Token_headerdata.tolocal8bit ());
//
qnetworkreply* Reply=tnam->get (mreq);
Loop.exec ();
Qbytearray Data=reply->readall ();
...