AI Crawler · Collection Records

Bot summary · Last 24 hours

curl — HTTP requests and diagnostics

A tool that sends HTTP requests and checks responses. Essential for service checks and API testing.
Markdown source·Anything to add or correct?

💬 "curl command"

curl sends HTTP requests and checks responses. It is the standard tool for web/API inspection.

Combinations like -I for headers only, -s/-o for quiet output, and -m for timeout are often used.

  • Concept: Sends requests over various protocols and prints the response.
  • Status code: Use -o /dev/null -w '%{http_code}' to extract only the code.
  • Headers: Use -I to view response headers.
  • Body: Prints the response body by default.

Commonly used options

OptionDescription
-IRequests headers only (HEAD)
-sSuppresses progress/error output
-m <seconds>Sets the overall operation timeout
-w '%{http_code} %{time_total}'Prints status code and elapsed time
-o /dev/nullDiscards the body

3 essential command combinations

  • curl -sI https://example.com | head -1 — Check response status and server headers
  • curl -s -o /dev/null -w '%{http_code}\n' http://127.0.0.1/health — Check health check status code
  • curl -s -m 5 -X POST -H 'Content-Type: application/json' -d '{"ping":true}' http://127.0.0.1/api/ping — Check API behavior

💬 "Show me an example that follows operational policy"

I've organized situations you commonly encounter on production servers in order.

Step 1 · Check status code

First check whether the service responds.


curl -s -o /dev/null -w '%{http_code}\n' http://127.0.0.1/health

Step 2 · Check headers

Look at redirect, cache, and server information.


curl -sI http://127.0.0.1/ | head

Step 3 · Check timing

Identify where latency occurs.


curl -s -o /dev/null -w '%{http_code} dns=%{time_namelookup} total=%{time_total}\n' http://127.0.0.1/

In practice, use it like this

1. Health check after deployment

Situation — Check that the service is healthy right after deployment.


for i in 1 2 3; do curl -s -o /dev/null -w '%{http_code}\n' http://127.0.0.1/health; sleep 1; done

Result — If 200 appears consistently, consider it healthy.

Point — If you add a health check to your deployment script, you can use it as an automatic rollback criterion.

2. Analyze response latency segments

Situation — External API calls are slow.


curl -s -o /dev/null -w 'dns=%{time_namelookup} conn=%{time_connect} tls=%{time_appconnect} total=%{time_total}\n' https://api.example.com/

Result — Break down DNS/TCP/TLS/overall time to find the bottleneck.

Point — If DNS is high, check the resolver; if TLS is high, check certificates/handshake.

Points to note

  • In automation, omitting -m can cause an indefinite wait.
  • Use -k (ignore certificate) only for diagnostics and don't put it in production scripts.
  • Putting tokens/passwords on the command line leaves them in shell history.
  • Calls to external URLs can fail depending on proxy/firewall.

Actual execution output

The result of checking the health check status code, response time, and server headers.

!curl command output: HTTP status and response time

Production server


Source (HTML): https://games.aidebatehub.com/programs/linux/network/curl.html This file is an auto-generated Markdown twin of the DevHub document.

Visitor Comments

Loading…
💬 Comments: 0 · Author type: human | Built: 2026-10-30T20:30:59+09:00