Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Meaning of libcurl messages and execution process

I am using libcurl library to fetch abc-1.tar file from server. I want to know meaning of message which is display and process of execution of libcurl to display this messages.

For Example: I provide some messages below out of that I know basic message meaning like Content-Length means length of file which are downloaded, etc.

I want meaning of all messages, particularly messages which are start with * (e. g. Connection #0 to host (nil) left intact)

* Re-using existing connection! (#0) with host (nil)
* Connected to (nil) (182.72.67.14) port 65101 (#0)
GET /...... HTTP/1.1
Host: 182.72.67.14:65101
Accept: */*
Connection:keep-alive
< HTTP/1.1 200 OK
< Cache-Control: private
< Content-Length: 186368
< Content-Type: application/x-tar
< Server: Microsoft-IIS/7.5
< Content-Disposition: attachment; filename=abc-1.tar
< X-AspNet-Version: 4.0.30319
< X-Powered-By: ASP.NET
< Date: Tue, 01 Oct 2013 06:29:00 GMT
< 
* Connection #0 to host (nil) left intact
like image 533
harshal bhavsar Avatar asked Oct 01 '13 06:10

harshal bhavsar


2 Answers

cURL's Man Page specifies three types of "special" verbose output:

A line starting with '>' means "header data" sent by curl, '<' means "header data" received by curl that is hidden in normal cases, and a line starting with '*' means additional info provided by curl.

You can read about HTTP header fields in the HTTP official publication page. Any other output lines displayed by cURL belong to the HTTP body carried by the corresponding message.

So what is the actual meaning of these informationals starting with *, you ask? They inform you about the status of the transfer's TCP connection with the host. For instance:

  • "Connected to (nil) (182.72.67.14) port 65101 (#0)" means that a TCP connection is established with the server side (in your case: 182.72.67.14). The #0 is the TCP session number (which is used only by cURL). The nil indicates that the host name couldn't be resolved via DNS (had it been resolved, the it would've appeared instead of nil).

  • "Connection #0 to host (nil) left intact" means that although the transfer is over, the TCP session itself is still open (i.e no FIN/ACK exchanges have been made), allowing you to keep reusing the same TCP connection for multiple transfers (which could be useful if you don't want to sacrifice time on opening a new TCP connection).

    The message "Re-using existing connection! (#0) with host (nil)" supports that, indicating that cURL does indeed that, riding an existing TCP connection (from a previous transfer).

like image 153
Eitan T Avatar answered Nov 04 '22 18:11

Eitan T


Marked by < are HTTP headers.You can read in detail about http headers and their meaning here and marked by * are verbose information provided by curl which is displayed on stderr.

like image 30
Arya Avatar answered Nov 04 '22 18:11

Arya