Hi guys,
I understand that a HttpJob (referring to the HttpJob in OKHttpUtils2) should not be re-used to submit concurrent connection.
But I tried to re-use it in a sequential way?
Many times, App uses a HttpJob to login Web Server. In order to keep track of the user session, web server will return a cookie in http header. Now, AFTER app receive successful response, is it OK to reuse this HttpJob object (without Release, Dim or Initialize again) and submit future request? This way, the future http request will contain the cookie automatically.
I did try the above approach in my project. It seems to work fine most of the time. But occasionally, it seems the HttpJob object does not send data to server.
I check the source code of OKHttpUtils2 and could not find any reason why I cannot re-use HttpJob sequentially. Actually, in HttpUtils2, OkHttpClient is re-used by multiple HttpJob concurrently.
(By the way, I did try the method in Forum and retrieve cookie from first HttpJob object and assign cookie to another HttpJob object but failed. That is another story.)
Now, my questions is:
1) Is it OK to re-used HttpJob sequentially?
2) If not, what is the reason?
Thank you very much.
I understand that a HttpJob (referring to the HttpJob in OKHttpUtils2) should not be re-used to submit concurrent connection.
But I tried to re-use it in a sequential way?
Many times, App uses a HttpJob to login Web Server. In order to keep track of the user session, web server will return a cookie in http header. Now, AFTER app receive successful response, is it OK to reuse this HttpJob object (without Release, Dim or Initialize again) and submit future request? This way, the future http request will contain the cookie automatically.
I did try the above approach in my project. It seems to work fine most of the time. But occasionally, it seems the HttpJob object does not send data to server.
I check the source code of OKHttpUtils2 and could not find any reason why I cannot re-use HttpJob sequentially. Actually, in HttpUtils2, OkHttpClient is re-used by multiple HttpJob concurrently.
(By the way, I did try the method in Forum and retrieve cookie from first HttpJob object and assign cookie to another HttpJob object but failed. That is another story.)
Now, my questions is:
1) Is it OK to re-used HttpJob sequentially?
2) If not, what is the reason?
Thank you very much.
Last edited: