DataRequest, FileRequest: send HeadersReceived notification

The "header" in this case is just the MIME type and content size, but we
must still send the notification when these are available. It will be
used for example in WebKit next release.
This commit is contained in:
Adrien Destugues
2015-02-06 15:19:38 +01:00
parent a2adc97219
commit ff75005a7a
2 changed files with 10 additions and 5 deletions
+7 -5
View File
@@ -60,22 +60,22 @@ BDataRequest::_ProtocolLoop()
data.Remove(0, separatorPosition + 1);
int pos = 0;
while(meta.Length() > 0)
while (meta.Length() > 0)
{
// Extract next parameter
pos = meta.FindFirst(';', pos);
BString parameter = meta;
if(pos >= 0) {
if (pos >= 0) {
parameter.Truncate(pos);
meta.Remove(0, pos+1);
} else
meta.Truncate(0);
// Interpret the parameter
if(parameter == "base64") {
if (parameter == "base64") {
isBase64 = true;
} else if(parameter.FindFirst("charset=") == 0) {
} else if (parameter.FindFirst("charset=") == 0) {
charset = parameter;
} else {
// Must be the MIME type
@@ -86,6 +86,7 @@ BDataRequest::_ProtocolLoop()
if (charset.Length() > 0)
mimeType << ";" << charset;
fResult.SetContentType(mimeType);
}
if (isBase64) {
@@ -104,7 +105,7 @@ BDataRequest::_ProtocolLoop()
// There may be some padding at the end of the base64 stream. This
// prevents us from computing the exact length we should get, so allow
// for some error margin.
if(length > data.Length() * 3 / 4
if (length > data.Length() * 3 / 4
|| length < data.Length() * 3 / 4 - 3) {
delete[] buffer;
return B_BAD_DATA;
@@ -117,6 +118,7 @@ BDataRequest::_ProtocolLoop()
fResult.SetLength(length);
if (fListener != NULL) {
fListener->HeadersReceived(this);
fListener->DownloadProgress(this, length, length);
if (length > 0)
fListener->DataReceived(this, payload, 0, length);
@@ -77,6 +77,8 @@ BFileRequest::_ProtocolLoop()
return error;
fResult.SetLength(size);
fListener->HeadersReceived(this);
ssize_t chunkSize;
char chunk[4096];
while ((chunkSize = file.Read(chunk, sizeof(chunk))) > 0) {
@@ -111,6 +113,7 @@ BFileRequest::_ProtocolLoop()
if (fListener != NULL) {
fListener->ConnectionOpened(this);
fListener->HeadersReceived(this);
// Add a parent directory entry.
fListener->DataReceived(this, "+/,\t..\r\n", transferredSize, 8);