int64_t checkStreamContent(PContentStream strm, PContentStream strmR) { l_info << L"checkStreamContent("; char buf[10000] = {0}; int64_t pos = 0; int32_t len = 0; while ((len = strmR->read(buf, 0, sizeof(buf))) > 0) { for (int32_t i = 0; i < len; i++) { unsigned b1 = (unsigned)(pos & 0xFF); unsigned b2 = (unsigned)(buf[i] & 0xFF); if (b1 != b2) { std::wstringstream msg; msg << L"Wrong byte at pos=" << pos; TASSERT(msg.str(), b1, b2); } pos++; } } int64_t nbOfBytes = strm->getContentLength(); if (nbOfBytes != -1) { TASSERT(L"#bytes", nbOfBytes, pos); TASSERT(L"contentLength", nbOfBytes, strmR->getContentLength()); } wstring csR = strmR->getContentType(); TASSERT(L"contentType", strm->getContentType(), csR); l_info << L")checkStreamContent=" << pos; return pos; }
void TestUtilHttp::tassert(const char* file, int line, const std::wstring& msg, PContentStream strm, PContentStream strmR) { com::wilutions::test::tassert(file, line, msg + L".contentLength", strm->getContentLength(), strmR->getContentLength()); char buf[2345], bufR[2345]; int32_t len = 0, lenR; while ((lenR = strm->read(bufR, 0, sizeof(bufR))) != -1) { com::wilutions::test::tassert(file, line, msg + L" read lenR != 0", true, lenR != 0); int32_t offs = 0; while ((len = strmR->read(buf, offs, lenR - offs)) != -1) { com::wilutions::test::tassert(file, line, msg + L" read len != 0", true, len != 0); if (len + offs == lenR) break; offs += len; } if (memcmp(buf, bufR, len)) { com::wilutions::test::tassert(file, line, msg + L".content-diff", 0, 1); } } if (strmR->getContentLength() != 0) { com::wilutions::test::tassert(file, line, msg + L".contentType", strm->getContentType(), strmR->getContentType()); } }
BINLINE void BContentStream::copyProperties(const PContentStream& rhs) { if (rhs) { contentType = rhs->getContentType(); contentLength = rhs->getContentLength(); fileName = rhs->getFileName(); attachmentCode = rhs->getAttachmentCode(); targetId = rhs->getTargetId(); } }