3

I am using curl to hit a server through an http post request and sending xml as request body, using the following piece of code :

curl -X POST -d @path to xml file URL

Ex: curl -X POST -d @C:\docs\test.xml http://www.example.com

which successfully returns the json http response as follows :

"header": {
    "product": "xxxxxxxxxx",
    "version": "xxxxxxxx"
},
"status": {
    "elapsedTime": 329,
    "httpReturnCode": 200,
    "statusCode": 0,
    "success": true,
    "startTime": 1350387905444,
    "statusDescription": "Successful"
},

But this json response doesn't show the endTime timestamp, the time at which the webservice call returns.

I know a way from curl to find out the response time of a url, using command :

curl -o /dev/null -w "Connect: %{time_connect} TTFB: %{time_starttransfer} Total time: %{time_total} n" http://www.google.com

The above command returns the response time in terms of milliseconds. Is there any way we can get the timestamp of http response using curl ? My requirement is to hit the server using http POST with a request body(XML file) and then get it response time in terms of timestamp. Any help is greatly appreciated.

4

1 回答 1

1

解决此问题的一种方法是包含环境变量调用 curl 的时间。然后你可以计算你的响应时间的绝对时间。

在 Windows 中,这将是

curl.exe -o NUL -w "Time: %TIME% Connect: %{time_connect} TTFB: %{time_starttransfer} Total time: %{time_total}\n" http://www.google.com
于 2015-10-12T08:44:47.887 回答