stream_ut_medium.cpp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #include "stream.h"
  2. #include <library/cpp/testing/unittest/registar.h>
  3. #include <util/stream/zlib.h>
  4. Y_UNIT_TEST_SUITE(THttpTestMedium) {
  5. Y_UNIT_TEST(TestCodings2) {
  6. TStringBuf data = "aaaaaaaaaaaaaaaaaaaaaaa";
  7. for (auto codec : SupportedCodings()) {
  8. if (codec == TStringBuf("z-zlib-0")) {
  9. continue;
  10. }
  11. if (codec == TStringBuf("z-null")) {
  12. continue;
  13. }
  14. TString s;
  15. {
  16. TStringOutput so(s);
  17. THttpOutput ho(&so);
  18. TBufferedOutput bo(&ho, 10000);
  19. bo << "HTTP/1.1 200 Ok\r\n"
  20. << "Connection: close\r\n"
  21. << "Content-Encoding: " << codec << "\r\n\r\n";
  22. for (size_t i = 0; i < 100; ++i) {
  23. bo << data;
  24. }
  25. }
  26. try {
  27. UNIT_ASSERT(s.size() > 10);
  28. UNIT_ASSERT(s.find(data) == TString::npos);
  29. } catch (...) {
  30. Cerr << codec << " " << s << Endl;
  31. throw;
  32. }
  33. {
  34. TStringInput si(s);
  35. THttpInput hi(&si);
  36. auto res = hi.ReadAll();
  37. UNIT_ASSERT(res.find(data) == 0);
  38. }
  39. }
  40. }
  41. } // THttpTestMedium suite