Bhavik Patel
Bhavik Patel

Reputation: 613

Curl taking too long to send https request using command line

I have implemented one shall script which send an https request to proxy with authorization header using GET request.

Here is my command :

curl -s -o /dev/null -w "%{http_code}" -X GET -H "Authorization: 123456:admin05" "https://www.mywebpage/api/request/india/?ID=123456&Number=9456123789&Code=01"

It takes around 12 second to wait and then sending request to proxy and revert back with some code like 200,400,500 etc..

Is it possible to reduce time and make it faster using CURL ?

Please advice me for such a case.

Thanks.

Upvotes: 1

Views: 7779

Answers (2)

ruisen2000
ruisen2000

Reputation: 27

I had the same problem, finally figured it out so hopefully this will help someone. The issue was the first DNS server in my DNS lookup was dead, so after 5 seconds when it timed out, it would try the next DNS server in your list.

On linux, check the DNS servers in /etc/resolv.conf and try pinging them, if your curl is taking a long time it could be because one or more of these are not responding.

Upvotes: 0

Amit G
Amit G

Reputation: 2423

Use option -v or --verbose along with --trace-time

It gives details of actions begin taken along with timings.

Includes DNS resolution, SSL handshake, etc. Line starting with '>' means header/body being sent, '<' means being received.

Based on difference between operation sequence - you can decipher whether server is taking time to respond (time between request and response) or network latency or bandwidth(response taking) time.

Upvotes: 2

Related Questions