送信されたカールリクエストのサイズを取得する


9

curlプログラムで要求のサイズを取得する方法はありますか?

例えば私がするなら

curl 'http://www.example.com/url' \
-H 'Cookie: cookie=cookiedata;' \
-H 'X-CSRFToken: csrffake' \
--data 'example=moredata \
--compressed

送信したリクエストの大きさを知りたいのですが?


ヘッダーリクエストのサイズは?
Braiam 2014

@Braiam結果のリクエストのサイズ(イーサネット/ IPレイヤーを除く)。だからヘッダー+データだと思います。
polym 2014

回答:


12

少しman curl掘り下げて、答えがわかったと思いますが、妥当性について100%確信はありません。

 -w, --write-out <format>
     Defines  what  to display on stdout after a completed and successful operation.
     [...]
     The variables present in the output format will be substituted by the
     value or text  that  curl thinks fit, as described below.
     All variables are specified as %{variable_name} and to output a
     normal % you just write them as %%.

     [...]
          size_request   The total amount of bytes
                         that were sent in the HTTP request.

          size_upload    The total amount of bytes that were uploaded.

つまり、a -w '%{size_request} %{size_upload}'を追加し、リクエストの後に出力に結果の数値を追加すると、合計でリクエストサイズが得られます。


1
注:HTTPを使用している場合、これにはTLSオーバーヘッドは含まれません。
dcoles
弊社のサイトを使用することにより、あなたは弊社のクッキーポリシーおよびプライバシーポリシーを読み、理解したものとみなされます。
Licensed under cc by-sa 3.0 with attribution required.