hrev48778 adds 1 changeset to branch 'master' old head: a2adc972197619ec439585d82912fb8b5854f465 new head: ff75005a7a54c47fac0c32552cf1b7f75c91131d overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=ff75005a7a54+%5Ea2adc9721976 ---------------------------------------------------------------------------- ff75005a7a54: 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. [ Adrien Destugues <pulkomandy@xxxxxxxxx> ] ---------------------------------------------------------------------------- Revision: hrev48778 Commit: ff75005a7a54c47fac0c32552cf1b7f75c91131d URL: http://cgit.haiku-os.org/haiku/commit/?id=ff75005a7a54 Author: Adrien Destugues <pulkomandy@xxxxxxxxx> Date: Fri Feb 6 14:14:06 2015 UTC ---------------------------------------------------------------------------- 2 files changed, 10 insertions(+), 5 deletions(-) src/kits/network/libnetapi/DataRequest.cpp | 12 +++++++----- src/kits/network/libnetapi/FileRequest.cpp | 3 +++ ---------------------------------------------------------------------------- diff --git a/src/kits/network/libnetapi/DataRequest.cpp b/src/kits/network/libnetapi/DataRequest.cpp index 9564b1c..b26b94f 100644 --- a/src/kits/network/libnetapi/DataRequest.cpp +++ b/src/kits/network/libnetapi/DataRequest.cpp @@ -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); diff --git a/src/kits/network/libnetapi/FileRequest.cpp b/src/kits/network/libnetapi/FileRequest.cpp index bfa803d..6c7410b 100644 --- a/src/kits/network/libnetapi/FileRequest.cpp +++ b/src/kits/network/libnetapi/FileRequest.cpp @@ -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);