Last Updated: August 15, 2019
·
8.36K
· haiqus

What's curl doing?

To see, run your curl command with --trace-ascii /dev/stdout</code> at the end, like so

$ curl -XGET http://localhost:9200/articles/_search -d '{"query":{"query_string":{"query":"cat"}}}' --trace-ascii /dev/stdout

You'll get a nice peek at the request/response loop

== Info: About to connect() to localhost port 9200 (#0)
== Info:   Trying ::1...
== Info: Connection refused
== Info:   Trying 127.0.0.1...
== Info: connected
== Info: Connected to localhost (127.0.0.1) port 9200 (#0)
=> Send header, 230 bytes (0xe6)
0000: GET /articles/_search HTTP/1.1
0020: User-Agent: curl/7.24.0 (x86_64-apple-darwin12.0) libcurl/7.24.0
0060:  OpenSSL/0.9.8r zlib/1.2.5
007c: Host: localhost:9200
0092: Accept: */*
009f: Content-Length: 42
00b3: Content-Type: application/x-www-form-urlencoded
00e4:
=> Send data, 42 bytes (0x2a)
0000: {"query":{"query_string":{"query":"cat"}}}
== Info: upload completely sent off: 42 out of 42 bytes
<= Recv header, 17 bytes (0x11)
0000: HTTP/1.1 200 OK
<= Recv header, 47 bytes (0x2f)
0000: Content-Type: application/json; charset=UTF-8
<= Recv header, 21 bytes (0x15)
0000: Content-Length: 122
<= Recv header, 2 bytes (0x2)
0000:
<= Recv data, 122 bytes (0x7a)
0000: {"took":0,"timed_out":false,"_shards":{"total":5,"successful":5,
0040: "failed":0},"hits":{"total":0,"max_score":null,"hits":[]}}
== Info: Connection #0 to host localhost left intact
{"took":0,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":0,"max_score":null,"hits":[]}}
== Info: Closing connection #0