c++ - 查找正文是否包含压缩数据

标签 c++ curl gzip

我有一个程序,它在 curl 请求的回复中搜索特定字符串。我有时会得到压缩数据。有没有办法找到回复是文本格式还是压缩格式? header 有时包含 gziipped、deflate header ,但它不一致。有没有办法搜索字符串并查看其是否已压缩?

最佳答案

您可以尝试查看数据的前两个字节。对于压缩数据,they should be 0x1f, 0x8b .

Member header and trailer

ID1 (IDentification 1)
ID2 (IDentification 2)
These have the fixed values ID1 = 31 (0x1f, \037), ID2 = 139 (0x8b, \213),
to identify the file as being in gzip format.

关于c++ - 查找正文是否包含压缩数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5631710/

相关文章:

php - curl 同一服务器时找不到 404

php - 将 cURL Cookie 复制给访问用户(使用 Javascript?)

python - 如何膨胀gzipped,base64d字符串

delphi - 如何解码gzip数据?

c++ - 如何使用OpenCV在不同的显示器上显示不同的窗口

c++ - USB-HID 读/写(重叠)WaitForSingleObject 不返回 C++

c++ - 重构建议 : How to avoid type checking in this OO design

ssl - Nginx 错误 https 。 curl : (35) error:1408F10B:SSL routines:ssl3_get_record:wrong version number

google-bigquery - 无法创建表 : Error while reading data, 错误消息:输入文件不是 Parquet 格式

c++ - 如何释放指针 vector ?