CLOUD: Refactor ConnectionManager/Requests system
ConnectionManager now storages Request * (not generates ids for it), Requests have control on their RequestState, RequestIdPair is now called Response and storages Request * with some response together. All related classes are changed to use it in more clean and understandable way. Request, RequestState and Response are carefully commented/documented.
This commit is contained in:
parent
83b349a033
commit
98150beb38
20 changed files with 325 additions and 239 deletions
|
@ -40,10 +40,10 @@ CurlRequest::~CurlRequest() {
|
|||
void CurlRequest::handle() {
|
||||
if (!_stream) _stream = new NetworkReadStream(_url.c_str(), _headersList, _postFields);
|
||||
|
||||
if (_stream && _stream->eos()) {
|
||||
if (_stream && _stream->eos()) {
|
||||
if (_stream->httpResponseCode() != 200)
|
||||
warning("HTTP response code is not 200 OK (it's %ld)", _stream->httpResponseCode());
|
||||
ConnMan.getRequestInfo(_id).state = Networking::FINISHED;
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -71,13 +71,13 @@ void CurlRequest::addPostField(Common::String keyValuePair) {
|
|||
_postFields += "&" + keyValuePair;
|
||||
}
|
||||
|
||||
Cloud::Storage::RequestReadStreamPair CurlRequest::execute() {
|
||||
NetworkReadStreamResponse CurlRequest::execute() {
|
||||
if (!_stream) {
|
||||
_stream = new NetworkReadStream(_url.c_str(), _headersList, _postFields);
|
||||
ConnMan.addRequest(this);
|
||||
}
|
||||
|
||||
return Cloud::Storage::RequestReadStreamPair(_id, _stream);
|
||||
return NetworkReadStreamResponse(this, _stream);
|
||||
}
|
||||
|
||||
} //end of namespace Networking
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue