NETWORKING: Enter Session

Session allows to reuse SessionRequests to the same host by making them
keeping alive connection. Turns out, though, that libcurl already does
that for us, and we didn't gain any speedup we thought we'd get.

Usage:
```
Networking::Session s;
Networking::SessionRequest *request = s.get(url);
request->startAndWait();
warning("HTTP GET: %s", request->text());
s.close();
```

You can still use SessionRequest without Session (but you can't put them
on stack!):
```
Networking::SessionRequest *request = new
Networking::SessionRequest(url);
request->startAndWait();
warning("HTTP GET: %s", request->text());
request->close();
```
This commit is contained in:
Alexander Tkachev 2019-11-03 02:16:00 +07:00 committed by Eugene Sandulenko
parent f7d9156967
commit 99e21f4320
8 changed files with 302 additions and 80 deletions

View file

@ -50,6 +50,8 @@ protected:
uint32 _bytesBufferSize;
bool _uploading; //using PUT method
bool _usingPatch; //using PATCH method
bool _keepAlive;
long _keepAliveIdle, _keepAliveInterval;
virtual NetworkReadStream *makeStream();
@ -85,6 +87,10 @@ public:
/** Remembers to use PATCH method when it would create NetworkReadStream. */
virtual void usePatch();
/** Remembers to use Connection: keep-alive or close. */
virtual void connectionKeepAlive(long idle = 120, long interval = 60);
virtual void connectionClose();
/**
* Starts this Request with ConnMan.
* @return its NetworkReadStream in NetworkReadStreamResponse.