Is there a way to get the size of a curl request programmatically?

E.g. if I do

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

I want to know how big my sent request is?

  • The header request size?
    – Braiam
    Commented Aug 17, 2014 at 15:40
  • @Braiam The size of the resulting request (excluding ethernet/ip layers). So header + data I think.
    – polym
    Commented Aug 17, 2014 at 15:45

1 Answer 1


Ok after some man curl digging, I think I've found out the answer, though I'm not 100% sure about it's validity:

 -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.

That means adding a -w '%{size_request} %{size_upload}' and then adding the resulting numbers in the output after the request will give you the request size in total.

  • 2
    Note: This doesn't include TLS overhead should you be using HTTPs.
    – dcoles
    Commented Apr 13, 2020 at 22:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .