diff --git a/src/kits/network/libnetapi/DataRequest.cpp b/src/kits/network/libnetapi/DataRequest.cpp index 9564b1c5ea..b26b94f552 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 bfa803d9ef..6c7410bedc 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);