static int parse_content_encoding(URLContext *h, const char *p) { if (!av_strncasecmp(p, "gzip", 4) || !av_strncasecmp(p, "deflate", 7)) { #if CONFIG_ZLIB HTTPContext *s = h->priv_data; s->compressed = 1; inflateEnd(&s->inflate_stream); if (inflateInit2(&s->inflate_stream, 32 + 15) != Z_OK) { av_log(h, AV_LOG_WARNING, "Error during zlib initialisation: %s\n", s->inflate_stream.msg); return AVERROR(ENOSYS); } if (zlibCompileFlags() & (1 << 17)) { av_log(h, AV_LOG_WARNING, "Your zlib was compiled without gzip support.\n"); return AVERROR(ENOSYS); } #else av_log(h, AV_LOG_WARNING, "Compressed (%s) content, need zlib with gzip support\n", p); return AVERROR(ENOSYS); #endif /* CONFIG_ZLIB */ } else if (!av_strncasecmp(p, "identity", 8)) { // The normal, no-encoding case (although servers shouldn't include // the header at all if this is the case). } else { av_log(h, AV_LOG_WARNING, "Unknown content coding: %s\n", p); } return 0; }
int main( int argc, char *argv[]) { Byte *compr, *uncompr; uLong comprLen = 10000*sizeof(int); /* don't overflow on MSDOS */ uLong uncomprLen = comprLen; static const char* myVersion = ZLIB_VERSION; if (zlibVersion()[0] != myVersion[0]) { fprintf(stderr, "incompatible zlib version\n"); exit(1); } else if (strcmp(zlibVersion(), ZLIB_VERSION) != 0) { fprintf(stderr, "warning: different zlib version\n"); } printf("zlib version %s = 0x%04x, compile flags = 0x%lx\n", ZLIB_VERSION, ZLIB_VERNUM, zlibCompileFlags()); compr = (Byte*)calloc((uInt)comprLen, 1); uncompr = (Byte*)calloc((uInt)uncomprLen, 1); /* compr and uncompr are cleared to avoid reading uninitialized * data and to ensure that uncompr compresses well. */ if (compr == Z_NULL || uncompr == Z_NULL) { printf("out of memory\n"); exit(1); } test_compress(compr, comprLen, uncompr, uncomprLen); test_gzio((argc > 1 ? argv[1] : TESTFILE), uncompr, uncomprLen); test_deflate(compr, comprLen); test_inflate(compr, comprLen, uncompr, uncomprLen); test_large_deflate(compr, comprLen, uncompr, uncomprLen); test_large_inflate(compr, comprLen, uncompr, uncomprLen); test_flush(compr, &comprLen); test_sync(compr, comprLen, uncompr, uncomprLen); comprLen = uncomprLen; test_dict_deflate(compr, comprLen); test_dict_inflate(compr, comprLen, uncompr, uncomprLen); free(compr); free(uncompr); return 0; }
END_TEST /* =========================================================================== * Test compress() and uncompress() */ START_TEST(test_compress_xunit) { Byte *compr, *uncompr; uLong comprLen = 10000*sizeof(int); /* don't overflow on MSDOS */ uLong uncomprLen = comprLen; static const char* myVersion = ZLIB_VERSION; ck_assert_int_eq(zlibVersion()[0] , myVersion[0]); ck_assert_int_eq(5.0,5); ck_assert_str_eq(zlibVersion(), ZLIB_VERSION); printf("zlib version %s = 0x%04x, compile flags = 0x%lx\n", ZLIB_VERSION, ZLIB_VERNUM, zlibCompileFlags()); compr = (Byte*)calloc((uInt)comprLen, 1); uncompr = (Byte*)calloc((uInt)uncomprLen, 1); ck_assert(compr != Z_NULL); ck_assert(uncompr != Z_NULL); int err; uLong len = (uLong)strlen(hello)+1; err = compress(compr, &comprLen, (const Bytef*)hello, len); ck_assert_int_eq(err,0); strcpy((char*)uncompr, "garbage"); err = uncompress(uncompr, &uncomprLen, compr, comprLen); ck_assert_int_eq(err,0); ck_assert_str_eq((char*)uncompr, hello); }
static uint32_t zlib125_zlibCompileFlags() { return static_cast<uint32_t>(zlibCompileFlags()); }