Keefe Tang via curl-users
2018-01-22 10:32:35 UTC
I find the verbose flag very useful to debug what headers curl sent
and received.
$ curl -svo /dev/null https://curl.haxx.se/
* Trying 151.101.2.49...
* TCP_NODELAY set
* Connected to curl.haxx.se (151.101.2.49) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
* successfully set certificate verify locations:
* CAfile: /etc/ssl/cert.pem
CApath: none
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
} [512 bytes data]
* TLSv1.2 (IN), TLS handshake, Server hello (2):
{ [102 bytes data]
* TLSv1.2 (IN), TLS handshake, Certificate (11):
{ [5397 bytes data]
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
{ [333 bytes data]
* TLSv1.2 (IN), TLS handshake, Server finished (14):
{ [4 bytes data]
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
} [70 bytes data]
* TLSv1.2 (OUT), TLS change cipher, Client hello (1):
} [1 bytes data]
* TLSv1.2 (OUT), TLS handshake, Finished (20):
} [16 bytes data]
* TLSv1.2 (IN), TLS change cipher, Client hello (1):
{ [1 bytes data]
* TLSv1.2 (IN), TLS handshake, Finished (20):
{ [16 bytes data]
* SSL connection using TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256
* ALPN, server accepted to use h2
* Server certificate:
* subject: C=US; ST=California; L=San Francisco; O=Fastly, Inc.;
CN=j2.shared.global.fastly.net
* start date: Dec 8 22:35:10 2017 GMT
* expire date: Apr 6 17:14:48 2018 GMT
* subjectAltName: host "curl.haxx.se" matched cert's "*.haxx.se"
* issuer: C=BE; O=GlobalSign nv-sa; CN=GlobalSign CloudSSL CA - SHA256 - G3
* SSL certificate verify ok.
* Using HTTP2, server supports multi-use
* Connection state changed (HTTP/2 confirmed)
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
* Using Stream ID: 1 (easy handle 0x7fd0bf80a400)
< HTTP/2 200
< date: Mon, 22 Jan 2018 10:24:39 GMT
< server: Apache
< x-frame-options: SAMEORIGIN
< last-modified: Mon, 22 Jan 2018 03:05:04 GMT
< etag: "201e-56354b261f474"
< cache-control: max-age=60
< expires: Mon, 22 Jan 2018 03:35:23 GMT
< strict-transport-security: max-age=31536000; includeSubDomains; preload
< content-type: text/html
< via: 1.1 varnish
< fastly-debug-digest:
118da82c63082081cb19f2e7bdaaaaf666ea031755480bfdba9d97b55fc9e57a
< accept-ranges: bytes
< via: 1.1 varnish
< age: 112
< x-served-by: cache-bma7027-BMA, cache-sin18035-SIN
< x-cache: HIT, HIT
< x-cache-hits: 1, 2
< x-timer: S1516616679.000262,VS0,VE0
< vary: Accept-Encoding
< content-length: 8222
<
{ [2367 bytes data]
* Connection #0 to host curl.haxx.se left intact
Can someone explain why when I try capturing the verbose output to a
shell variable, I get the following result and how I can capture the
same output as I see in terminal?
$ req=$( curl -svo /dev/null https://curl.haxx.se/ 2>&1 ); echo $req
a Trying 151.101.2.49... a TCP_NODELAY set a Connected to curl.haxx.se
(151.101.2.49) port 443 (#0) a ALPN, offering h2 a ALPN, offering
http/1.1 a Cipher selection:
ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH a
successfully set certificate verify locations: a CAfile:
/etc/ssl/cert.pem CApath: none a TLSv1.2 (OUT), TLS handshake, Client
hello (1): } [512 bytes data] a TLSv1.2 (IN), TLS handshake, Server
hello (2): { [102 bytes data] a TLSv1.2 (IN), TLS handshake,
Certificate (11): { [5397 bytes data] a TLSv1.2 (IN), TLS handshake,
Server key exchange (12): { [333 bytes data] a TLSv1.2 (IN), TLS
handshake, Server finished (14): { [4 bytes data] a TLSv1.2 (OUT), TLS
handshake, Client key exchange (16): } [70 bytes data] a TLSv1.2
(OUT), TLS change cipher, Client hello (1): } [1 bytes data] a TLSv1.2
(OUT), TLS handshake, Finished (20): } [16 bytes data] a TLSv1.2 (IN),
TLS change cipher, Client hello (1): { [1 bytes data] a TLSv1.2 (IN),
TLS handshake, Finished (20): { [16 bytes data] a SSL connection using
TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256 a ALPN, server accepted to use
h2 a Server certificate: a subject: C=US; ST=California; L=San
Francisco; O=Fastly, Inc.; CN=j2.shared.global.fastly.net a start
date: Dec 8 22:35:10 2017 GMT a expire date: Apr 6 17:14:48 2018 GMT a
subjectAltName: host "curl.haxx.se" matched cert's "*.haxx.se" a
issuer: C=BE; O=GlobalSign nv-sa; CN=GlobalSign CloudSSL CA - SHA256 -
G3 a SSL certificate verify ok. a Using HTTP2, server supports
multi-use a Connection state changed (HTTP/2 confirmed)
{ [2366 bytes data] a Connection #0 to host curl.haxx.se left
intactbfdba9d97b55fc9e57a Stream ID: 1 (easy handle 0x7ff722005800) >
GET / HTTP/2
-----------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-users
Etiquette: https://curl.hax
and received.
$ curl -svo /dev/null https://curl.haxx.se/
* Trying 151.101.2.49...
* TCP_NODELAY set
* Connected to curl.haxx.se (151.101.2.49) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
* successfully set certificate verify locations:
* CAfile: /etc/ssl/cert.pem
CApath: none
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
} [512 bytes data]
* TLSv1.2 (IN), TLS handshake, Server hello (2):
{ [102 bytes data]
* TLSv1.2 (IN), TLS handshake, Certificate (11):
{ [5397 bytes data]
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
{ [333 bytes data]
* TLSv1.2 (IN), TLS handshake, Server finished (14):
{ [4 bytes data]
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
} [70 bytes data]
* TLSv1.2 (OUT), TLS change cipher, Client hello (1):
} [1 bytes data]
* TLSv1.2 (OUT), TLS handshake, Finished (20):
} [16 bytes data]
* TLSv1.2 (IN), TLS change cipher, Client hello (1):
{ [1 bytes data]
* TLSv1.2 (IN), TLS handshake, Finished (20):
{ [16 bytes data]
* SSL connection using TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256
* ALPN, server accepted to use h2
* Server certificate:
* subject: C=US; ST=California; L=San Francisco; O=Fastly, Inc.;
CN=j2.shared.global.fastly.net
* start date: Dec 8 22:35:10 2017 GMT
* expire date: Apr 6 17:14:48 2018 GMT
* subjectAltName: host "curl.haxx.se" matched cert's "*.haxx.se"
* issuer: C=BE; O=GlobalSign nv-sa; CN=GlobalSign CloudSSL CA - SHA256 - G3
* SSL certificate verify ok.
* Using HTTP2, server supports multi-use
* Connection state changed (HTTP/2 confirmed)
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
* Using Stream ID: 1 (easy handle 0x7fd0bf80a400)
GET / HTTP/2
Host: curl.haxx.se
User-Agent: Mozilla/5.0 Firefox/34.5
Accept: */*
* Connection state changed (MAX_CONCURRENT_STREAMS updated)!Host: curl.haxx.se
User-Agent: Mozilla/5.0 Firefox/34.5
Accept: */*
< HTTP/2 200
< date: Mon, 22 Jan 2018 10:24:39 GMT
< server: Apache
< x-frame-options: SAMEORIGIN
< last-modified: Mon, 22 Jan 2018 03:05:04 GMT
< etag: "201e-56354b261f474"
< cache-control: max-age=60
< expires: Mon, 22 Jan 2018 03:35:23 GMT
< strict-transport-security: max-age=31536000; includeSubDomains; preload
< content-type: text/html
< via: 1.1 varnish
< fastly-debug-digest:
118da82c63082081cb19f2e7bdaaaaf666ea031755480bfdba9d97b55fc9e57a
< accept-ranges: bytes
< via: 1.1 varnish
< age: 112
< x-served-by: cache-bma7027-BMA, cache-sin18035-SIN
< x-cache: HIT, HIT
< x-cache-hits: 1, 2
< x-timer: S1516616679.000262,VS0,VE0
< vary: Accept-Encoding
< content-length: 8222
<
{ [2367 bytes data]
* Connection #0 to host curl.haxx.se left intact
Can someone explain why when I try capturing the verbose output to a
shell variable, I get the following result and how I can capture the
same output as I see in terminal?
$ req=$( curl -svo /dev/null https://curl.haxx.se/ 2>&1 ); echo $req
a Trying 151.101.2.49... a TCP_NODELAY set a Connected to curl.haxx.se
(151.101.2.49) port 443 (#0) a ALPN, offering h2 a ALPN, offering
http/1.1 a Cipher selection:
ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH a
successfully set certificate verify locations: a CAfile:
/etc/ssl/cert.pem CApath: none a TLSv1.2 (OUT), TLS handshake, Client
hello (1): } [512 bytes data] a TLSv1.2 (IN), TLS handshake, Server
hello (2): { [102 bytes data] a TLSv1.2 (IN), TLS handshake,
Certificate (11): { [5397 bytes data] a TLSv1.2 (IN), TLS handshake,
Server key exchange (12): { [333 bytes data] a TLSv1.2 (IN), TLS
handshake, Server finished (14): { [4 bytes data] a TLSv1.2 (OUT), TLS
handshake, Client key exchange (16): } [70 bytes data] a TLSv1.2
(OUT), TLS change cipher, Client hello (1): } [1 bytes data] a TLSv1.2
(OUT), TLS handshake, Finished (20): } [16 bytes data] a TLSv1.2 (IN),
TLS change cipher, Client hello (1): { [1 bytes data] a TLSv1.2 (IN),
TLS handshake, Finished (20): { [16 bytes data] a SSL connection using
TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256 a ALPN, server accepted to use
h2 a Server certificate: a subject: C=US; ST=California; L=San
Francisco; O=Fastly, Inc.; CN=j2.shared.global.fastly.net a start
date: Dec 8 22:35:10 2017 GMT a expire date: Apr 6 17:14:48 2018 GMT a
subjectAltName: host "curl.haxx.se" matched cert's "*.haxx.se" a
issuer: C=BE; O=GlobalSign nv-sa; CN=GlobalSign CloudSSL CA - SHA256 -
G3 a SSL certificate verify ok. a Using HTTP2, server supports
multi-use a Connection state changed (HTTP/2 confirmed)
{ [2366 bytes data] a Connection #0 to host curl.haxx.se left
intactbfdba9d97b55fc9e57a Stream ID: 1 (easy handle 0x7ff722005800) >
GET / HTTP/2
-----------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-users
Etiquette: https://curl.hax