Make option redirect output from `--output/-o` to `stdin`
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
从 httpie/cli/argparser.py 中的 _setup_standard_streams() 开始,traceback 显示这里对输出流调用了 seek(0),然后跟踪 --output 如何通过 httpie/core.py 进行处理。使用 -o - 和二进制响应复现该命令;当输出到达 stdout,并且可以在不出现 seekability 错误的情况下通过管道传给 head 或 xxd 时,就完成了。
由索引模型根据 Issue 内容生成。
描述
Checklist
- I've searched for similar feature requests.
Enhancement request
I want to be able to redirect the output when using the --output/-o flag to the stdin like this:
http www.example.com/?req=index.html --output -
Currently if I run it this way, it shows this error message:
Traceback (most recent call last):
File "/home/user/.local/bin/http", line 8, in <module>
sys.exit(main())
File "/home/user/.local/lib/python3.10/site-packages/httpie/__main__.py", line 9, in main
exit_status = main()
File "/home/user/.local/lib/python3.10/site-packages/httpie/core.py", line 162, in main
return raw_main(
File "/home/user/.local/lib/python3.10/site-packages/httpie/core.py", line 77, in raw_main
parsed_args = parser.parse_args(
File "/home/user/.local/lib/python3.10/site-packages/httpie/cli/argparser.py", line 172, in parse_args
self._setup_standard_streams()
File "/home/user/.local/lib/python3.10/site-packages/httpie/cli/argparser.py", line 250, in _setup_standard_streams
self.args.output_file.seek(0)
io.UnsupportedOperation: File or stream is not seekable.
Problem it solves
I know if the output format is normal we don't have to use this. But when the output is binary or the file contains some null bytes somewhere like %00 http won't show the output. But we can rather use the --output/-o to redirect the binary to a file.
I don't want to redirect to a new file, I just want to check the file content in a single command. This is more productive because I can now redirect the input stream to other programs like head, xxd etc.
Like this:
http example.com/binary -b --output - | head | xxd
- 主要语言
- Python
- 星标
- 38.6k
- 派生
- 4k
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
httpie/cli 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
new
难度 2/5 1-3 小时 新手友好度 70/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
bug new
难度 4/5 3-5 天 新手友好度 48/100
维护者通常 1 天内回复
相似的 Issue
-
correction metadata
难度 2/5 1-3 小时 新手友好度 68/100
acl-org/acl-anthology#10104 · 1 条评论 ·
维护者通常 1 天内回复
-
bug status/needs-triage
难度 2/5 1-3 小时 新手友好度 86/100
prowler-cloud/prowler#12885 · 1 条评论 ·
维护者通常 1 天内回复
-
Bug in GaussianTailProbabilityCalibrator: running_statistics=False still uses a windowed variance未关闭bug good first issue
难度 2/5 1-3 小时 新手友好度 88/100
selimfirat/pysad#107 ·
维护者通常 1 天内回复
-
bug ci-failure high priority
难度 1/5 1 小时以内 新手友好度 88/100
vllm-project/vllm-omni#8194 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 88/100
维护者通常 1 天内回复