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:
@@ -60,22 +60,22 @@ BDataRequest::_ProtocolLoop()
|
|||||||
data.Remove(0, separatorPosition + 1);
|
data.Remove(0, separatorPosition + 1);
|
||||||
|
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
while(meta.Length() > 0)
|
while (meta.Length() > 0)
|
||||||
{
|
{
|
||||||
// Extract next parameter
|
// Extract next parameter
|
||||||
pos = meta.FindFirst(';', pos);
|
pos = meta.FindFirst(';', pos);
|
||||||
|
|
||||||
BString parameter = meta;
|
BString parameter = meta;
|
||||||
if(pos >= 0) {
|
if (pos >= 0) {
|
||||||
parameter.Truncate(pos);
|
parameter.Truncate(pos);
|
||||||
meta.Remove(0, pos+1);
|
meta.Remove(0, pos+1);
|
||||||
} else
|
} else
|
||||||
meta.Truncate(0);
|
meta.Truncate(0);
|
||||||
|
|
||||||
// Interpret the parameter
|
// Interpret the parameter
|
||||||
if(parameter == "base64") {
|
if (parameter == "base64") {
|
||||||
isBase64 = true;
|
isBase64 = true;
|
||||||
} else if(parameter.FindFirst("charset=") == 0) {
|
} else if (parameter.FindFirst("charset=") == 0) {
|
||||||
charset = parameter;
|
charset = parameter;
|
||||||
} else {
|
} else {
|
||||||
// Must be the MIME type
|
// Must be the MIME type
|
||||||
@@ -86,6 +86,7 @@ BDataRequest::_ProtocolLoop()
|
|||||||
if (charset.Length() > 0)
|
if (charset.Length() > 0)
|
||||||
mimeType << ";" << charset;
|
mimeType << ";" << charset;
|
||||||
fResult.SetContentType(mimeType);
|
fResult.SetContentType(mimeType);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isBase64) {
|
if (isBase64) {
|
||||||
@@ -104,7 +105,7 @@ BDataRequest::_ProtocolLoop()
|
|||||||
// There may be some padding at the end of the base64 stream. This
|
// 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
|
// prevents us from computing the exact length we should get, so allow
|
||||||
// for some error margin.
|
// for some error margin.
|
||||||
if(length > data.Length() * 3 / 4
|
if (length > data.Length() * 3 / 4
|
||||||
|| length < data.Length() * 3 / 4 - 3) {
|
|| length < data.Length() * 3 / 4 - 3) {
|
||||||
delete[] buffer;
|
delete[] buffer;
|
||||||
return B_BAD_DATA;
|
return B_BAD_DATA;
|
||||||
@@ -117,6 +118,7 @@ BDataRequest::_ProtocolLoop()
|
|||||||
fResult.SetLength(length);
|
fResult.SetLength(length);
|
||||||
|
|
||||||
if (fListener != NULL) {
|
if (fListener != NULL) {
|
||||||
|
fListener->HeadersReceived(this);
|
||||||
fListener->DownloadProgress(this, length, length);
|
fListener->DownloadProgress(this, length, length);
|
||||||
if (length > 0)
|
if (length > 0)
|
||||||
fListener->DataReceived(this, payload, 0, length);
|
fListener->DataReceived(this, payload, 0, length);
|
||||||
|
|||||||
@@ -77,6 +77,8 @@ BFileRequest::_ProtocolLoop()
|
|||||||
return error;
|
return error;
|
||||||
fResult.SetLength(size);
|
fResult.SetLength(size);
|
||||||
|
|
||||||
|
fListener->HeadersReceived(this);
|
||||||
|
|
||||||
ssize_t chunkSize;
|
ssize_t chunkSize;
|
||||||
char chunk[4096];
|
char chunk[4096];
|
||||||
while ((chunkSize = file.Read(chunk, sizeof(chunk))) > 0) {
|
while ((chunkSize = file.Read(chunk, sizeof(chunk))) > 0) {
|
||||||
@@ -111,6 +113,7 @@ BFileRequest::_ProtocolLoop()
|
|||||||
|
|
||||||
if (fListener != NULL) {
|
if (fListener != NULL) {
|
||||||
fListener->ConnectionOpened(this);
|
fListener->ConnectionOpened(this);
|
||||||
|
fListener->HeadersReceived(this);
|
||||||
|
|
||||||
// Add a parent directory entry.
|
// Add a parent directory entry.
|
||||||
fListener->DataReceived(this, "+/,\t..\r\n", transferredSize, 8);
|
fListener->DataReceived(this, "+/,\t..\r\n", transferredSize, 8);
|
||||||
|
|||||||
Reference in New Issue
Block a user