Make option redirect output from `--output/-o` to `stdin`
まだ誰も着手していません。
評価
調査の方向性
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 にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
httpie/cli のほかの issue
-
new
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
bug new
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
-
難易度 3/5 1〜2日 初心者へのやさしさ 55/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
似ている issue
-
agent-ready documentation needs-triage
難易度 1/5 1〜3時間 初心者へのやさしさ 88/100
-
documentation
難易度 1/5 1時間未満 初心者へのやさしさ 91/100
-
workflow-status page template still says reusable workflows are "triggered only by workflow_call:" オープン
難易度 1/5 1時間未満 初心者へのやさしさ 92/100
-
instance instance add
難易度 1/5 1時間未満 初心者へのやさしさ 72/100
searxng/searx-instances#939 · コメント 1 件 ·
-
area-deployment area-integrations triage:bot-seen
難易度 2/5 半日 初心者へのやさしさ 86/100