Trace using cURL Command Example


The -v or --verbose is a really good cURL command option to get more details about the HTTP requests. But there are other options called --trace and --trace-ascii that can come in quite handy when you may want to get the complete stream of the transferred data.

Example:
% curl --trace data.txt https://code2care.org

We have stored the output in data.txt file.

% head -n 50 data.txt                        
== Info:   Trying 104.21.91.10:443...
== Info: Connected to code2care.org (104.21.91.10) port 443 (#0)
== Info: ALPN: offers h2
== Info: ALPN: offers http/1.1
== Info:  CAfile: /etc/ssl/cert.pem
== Info:  CApath: none
== Info: (304) (OUT), TLS handshake, Client hello (1):
=> Send SSL data, 318 bytes (0x13e)
0000: 01 00 01 3a 03 03 79 7a bc 90 ed fc 48 96 8e e5 ...:..yz....H...
0010: a4 74 47 ab 53 d0 16 1e a6 19 d9 0f 04 50 a3 87 .tG.S........P..
0020: 35 d0 31 78 3d dc 20 0f bd e1 f1 85 36 c2 b0 c9 5.1x=. .....6...
0030: 02 ed fb 2f c4 3a d9 c0 dd ff 33 9b da 07 98 bb .../.:....3.....
0040: a6 07 7a 29 ac 49 08 00 62 13 03 13 02 13 01 cc ..z).I..b.......
0050: a9 cc a8 cc aa c0 30 c0 2c c0 28 c0 24 c0 14 c0 ......0.,.(.$...
0060: 0a 00 9f 00 6b 00 39 ff 85 00 c4 00 88 00 81 00 ....k.9.........
0070: 9d 00 3d 00 35 00 c0 00 84 c0 2f c0 2b c0 27 c0 ..=.5...../.+.'.
0080: 23 c0 13 c0 09 00 9e 00 67 00 33 00 be 00 45 00 #.......g.3...E.
0090: 9c 00 3c 00 2f 00 ba 00 41 c0 11 c0 07 00 05 00 ..<./...A.......
00a0: 04 c0 12 c0 08 00 16 00 0a 00 ff 01 00 00 8f 00 ................
00b0: 2b 00 09 08 03 04 03 03 03 02 03 01 00 33 00 26 +............3.&
00c0: 00 24 00 1d 00 20 94 cf a2 d1 46 08 76 71 55 ba .$... ....F.vqU.
00d0: 8a fc 03 68 c9 61 aa e7 e3 9a 60 81 17 bc 29 ac ...h.a....`...).
00e0: e5 14 c3 85 d7 68 00 00 00 12 00 10 00 00 0d 63 .....h.........c
00f0: 6f 64 65 32 63 61 72 65 2e 6f 72 67 00 0b 00 02 ode2care.org....
0100: 01 00 00 0a 00 0a 00 08 00 1d 00 17 00 18 00 19 ................
0110: 00 0d 00 18 00 16 08 06 06 01 06 03 08 05 05 01 ................
0120: 05 03 08 04 04 01 04 03 02 01 02 03 00 10 00 0e ................
0130: 00 0c 02 68 32 08 68 74 74 70 2f 31 2e 31       ...h2.http/1.1
== Info: (304) (IN), TLS handshake, Server hello (2):
<= Recv SSL data, 122 bytes (0x7a)
0000: 02 00 00 76 03 03 e5 44 54 3a 7f 13 ba bf 84 0a ...v...DT:......
0010: 40 be 90 f0 81 93 02 cf cc 76 05 d4 72 59 1d 0b @........v..rY..
0020: a6 2e dc 82 d3 88 20 0f bd e1 f1 85 36 c2 b0 c9 ...... .....6...
0030: 02 ed fb 2f c4 3a d9 c0 dd ff 33 9b da 07 98 bb .../.:....3.....
0040: a6 07 7a 29 ac 49 08 13 03 00 00 2e 00 33 00 24 ..z).I.......3.$
0050: 00 1d 00 20 64 cf b9 73 63 55 18 2c 47 87 b5 3e ... d..scU.,G..>
0060: a8 ac 5a e3 8f 23 18 5b e6 d5 f1 38 62 86 84 ea ..Z..#.[...8b...
0070: 29 49 94 59 00 2b 00 02 03 04                   )I.Y.+....
== Info: (304) (IN), TLS handshake, Unknown (8):
<= Recv SSL data, 19 bytes (0x13)
0000: 08 00 00 0f 00 0d 00 00 00 00 00 10 00 05 00 03 ................
0010: 02 68 32                                        .h2
== Info: (304) (IN), TLS handshake, Certificate (11):
<= Recv SSL data, 2334 bytes (0x91e)
0000: 0b 00 09 1a 00 00 09 16 00 05 3b 30 82 05 37 30 ..........;0..70
0010: 82 04 dd a0 03 02 01 02 02 10 04 37 10 eb 4b f7 ...........7..K.
0020: 61 23 e9 69 2b f5 1f be 31 5a 30 0a 06 08 2a 86 a#.i+...1Z0...*.
0030: 48 ce 3d 04 03 02 30 4a 31 0b 30 09 06 03 55 04 H.=...0J1.0...U.
0040: 06 13 02 55 53 31 19 30 17 06 03 55 04 0a 13 10 ...US1.0...U....
0050: 43 6c 6f 75 64 66 6c 61 72 65 2c 20 49 6e 63 2e Cloudflare, Inc.
...
...
...
<= Recv data, 1104 bytes (0x450)
0000: 3c 21 44 4f 43 54 59 50 45 20 68 74 6d 6c 3e 3c <!DOCTYPE html><
0010: 68 74 6d 6c 20 6c 61 6e 67 3d 22 65 6e 2d 55 53 html lang="en-US
0020: 22 3e 3c 68 65 61 64 3e 3c 6d 65 74 61 20 63 68 "><head><meta ch
0030: 61 72 73 65 74 3d 22 75 74 66 2d 38 22 2f 3e 0a arset="utf-8"/>.
0040: 3c 73 63 72 69 70 74 20 64 61 74 61 2d 65 7a 73 <script data-ezs
0050: 63 72 65 78 3d 27 66 61 6c 73 65 27 20 64 61 74 crex='false' dat
0060: 61 2d 63 66 61 73 79 6e 63 3d 27 66 61 6c 73 65 a-cfasync='false
0070: 27 20 64 61 74 61 2d 70 61 67 65 73 70 65 65 64 ' data-pagespeed
0080: 2d 6e 6f 2d 64 65 66 65 72 3e 76 61 72 20 5f 5f -no-defer>var __
0090: 65 7a 3d 5f 5f 65 7a 7c 7c 7b 7d 3b 5f 5f 65 7a ez=__ez||{};__ez
00a0: 2e 73 74 6d 73 3d 44 61 74 65 2e 6e 6f 77 28 29 .stms=Date.now()

We can see details of every data byte sent and received via the SSL layer in hexadecimal.

If you just want to see the details in ASCII make use of the option --trace-ascii

Example:
% head -n 100 data.txt                          
== Info:   Trying 172.67.164.66:443...
== Info: Connected to code2care.org (172.67.164.66) port 443 (#0)
== Info: ALPN: offers h2
== Info: ALPN: offers http/1.1
== Info:  CAfile: /etc/ssl/cert.pem
== Info:  CApath: none
== Info: (304) (OUT), TLS handshake, Client hello (1):
=> Send SSL data, 318 bytes (0x13e)
0000: ...:..)...'..{r....i9.z...o.~.}Qu.b..~ .d-O..O..... ....6.3...o.
0040: .qY...P.b.............0.,.(.$.......k.9...........=.5...../.+.'.
0080: #.......g.3...E...<./...A.......................+............3.&
00c0: .$... .......^..b.......a.........k.F".........code2care.org....
0100: ...................................................h2.http/1.1
== Info: (304) (IN), TLS handshake, Server hello (2):
<= Recv SSL data, 122 bytes (0x7a)
0000: ...v.....3.;.@=fb.e...X....!#PDX%.h.r. .d-O..O..... ....6.3...o.
0040: .qY...P......3.$... .(k..{P.Pb4p..v1."...~...>.......+....
== Info: (304) (IN), TLS handshake, Unknown (8):
<= Recv SSL data, 19 bytes (0x13)
0000: .................h2
== Info: (304) (IN), TLS handshake, Certificate (11):
<= Recv SSL data, 2334 bytes (0x91e)
0000: ..........;0..70...........7..K.a#.i+...1Z0...*.H.=...0J1.0...U.
0040: ...US1.0...U....Cloudflare, Inc.1 0...U....Cloudflare Inc ECC CA
...
...
trace command with cURL example
-


Have Questions? Post them here!

Top Hashtags:

Advertisements

Advertisements




Advertisements