python-requests - Jython 错误:java.util.zip.DataFormatException:设置的代码长度无效
问题描述
当我使用 Python requests 模块进行 API 调用时使用 StreamSets Jython (Python 2.7) 处理器
r = requests.get("https://someurl.com", headers={"Authorization":"Bearer sometokenstring"})
我收到一个错误:
INFO java.util.zip.DataFormatException: invalid code lengths set.
相同的代码在带有 Python 2.7 的 linux 终端中运行而没有此错误。有什么想法可以解决这个错误吗?
解决方案
这通过添加请求标头属性得到解决:“Accept-Encoding”:“deflate”,因为 zip 格式数据导致了一些问题。所以现在请求看起来像:
r = requests.get("https://someurl.com", headers={"Authorization":"Bearer sometokenstring","Accept-Encoding":"deflate"})
推荐阅读
- kdb - 如何选择/执行包含“。”的列?
- c# - 实体框架和 MSSQL json_value 嵌套数组在不同的行中
- javascript - 调用 clear() 时不清除本地存储,然后在同一函数中设置一些本地存储值
- ios - 使用 ARKit 加载的 3d 文件是否有大小限制?
- c# - 验证属性时将两个正则表达式合二为一
- macos - 向 macOS Mojave LaunchDaemon 授予相机权限
- memory-leaks - 在模型上运行推理时 mxnet cpu 内存泄漏
- loops - Shopify 循环 - 如果变体没有图像,则跳过产品变体
- python - 从对应于列值的熊猫数据框中随机选择所有行的有效方法
- visual-studio - 使用 Visual Studio 即时窗口将数组内容保存到文件