Help us understand the problem. What is going on with this article?

http のデバッグに nc (netcat) が効く

More than 5 years have passed since last update.

Webアプリケーション開発者たるもの、時には生 http リクエストと戦わねばならない時があるのです。主に multipart とか multipart とか multipart とか。

そんな時は適当なマシンで

nc -l 8080 > request_dump.txt

で口を開けて待たせておいて、form の投げ先を書き換えて投げつけてやれば、request_dump.txt に 生 http リクエストがダンプされます。(ブラウザは応答待ちのままになるので、ダンプが取れたら nc を kill する)

ダンプしたリクエストを以下のようにしてアプリへ投げつけてやれば、再現試験も簡単。ループでぶん回すのも自由自在。 ( Cookie や、Host など一部のヘッダは投げる前に書き換えが必要)

cat request_dump.txt | nc $HOSTNAME 80

ちなみに、受け側のアプリが https な場合は openssl の助けを借りれば同じことができます。

cat request_dump.txt | openssl s_client -connect $HOSTNAME:443

Enjoy!!

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした