GopherRequest: Accurate progress reports and listener bugfixes
This commit brings the following changes: - DownloadProgress() should now be reported for every DataReceived() calls, similar to other BUrlRequest classes. - Properly verify whether a listener has been set before invoking them. Change-Id: I4ded82e318ba580b8869c3d1751da4e36882c39f Reviewed-on: https://review.haiku-os.org/c/haiku/+/3075 Reviewed-by: waddlesplash <[email protected]>
This commit is contained in:
@@ -360,6 +360,9 @@ BGopherRequest::_ProtocolLoop()
|
|||||||
|
|
||||||
fPosition += fInputBuffer.Size();
|
fPosition += fInputBuffer.Size();
|
||||||
|
|
||||||
|
if (fListener != NULL)
|
||||||
|
fListener->DownloadProgress(this, fPosition, 0);
|
||||||
|
|
||||||
// XXX: this is plain stupid, we already copied the data
|
// XXX: this is plain stupid, we already copied the data
|
||||||
// and just want to drop it...
|
// and just want to drop it...
|
||||||
char *inputTempBuffer = new(std::nothrow) char[bytesRead];
|
char *inputTempBuffer = new(std::nothrow) char[bytesRead];
|
||||||
@@ -372,11 +375,8 @@ BGopherRequest::_ProtocolLoop()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fPosition > 0) {
|
if (fPosition > 0)
|
||||||
fResult.SetLength(fPosition);
|
fResult.SetLength(fPosition);
|
||||||
if (fListener != NULL)
|
|
||||||
fListener->DownloadProgress(this, fPosition, fPosition);
|
|
||||||
}
|
|
||||||
|
|
||||||
fSocket->Disconnect();
|
fSocket->Disconnect();
|
||||||
|
|
||||||
@@ -668,17 +668,27 @@ BGopherRequest::_ParseInput(bool last)
|
|||||||
"</div>\n"
|
"</div>\n"
|
||||||
"<h1>" << pageTitle << "</h1>\n";
|
"<h1>" << pageTitle << "</h1>\n";
|
||||||
|
|
||||||
fListener->DataReceived(this, header.String(), fPosition,
|
if (fListener != NULL) {
|
||||||
header.Length());
|
fListener->DataReceived(this, header.String(), fPosition,
|
||||||
|
header.Length());
|
||||||
|
}
|
||||||
|
|
||||||
fPosition += header.Length();
|
fPosition += header.Length();
|
||||||
|
|
||||||
|
if (fListener != NULL)
|
||||||
|
fListener->DownloadProgress(this, fPosition, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item.Length()) {
|
if (item.Length()) {
|
||||||
fListener->DataReceived(this, item.String(), fPosition,
|
if (fListener != NULL) {
|
||||||
item.Length());
|
fListener->DataReceived(this, item.String(), fPosition,
|
||||||
|
item.Length());
|
||||||
|
}
|
||||||
|
|
||||||
fPosition += item.Length();
|
fPosition += item.Length();
|
||||||
|
|
||||||
|
if (fListener != NULL)
|
||||||
|
fListener->DownloadProgress(this, fPosition, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -689,10 +699,15 @@ BGopherRequest::_ParseInput(bool last)
|
|||||||
"</body>\n"
|
"</body>\n"
|
||||||
"</html>\n";
|
"</html>\n";
|
||||||
|
|
||||||
fListener->DataReceived(this, footer.String(), fPosition,
|
if (fListener != NULL) {
|
||||||
footer.Length());
|
fListener->DataReceived(this, footer.String(), fPosition,
|
||||||
|
footer.Length());
|
||||||
|
}
|
||||||
|
|
||||||
fPosition += footer.Length();
|
fPosition += footer.Length();
|
||||||
|
|
||||||
|
if (fListener != NULL)
|
||||||
|
fListener->DownloadProgress(this, fPosition, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user