~/docs /curl HTTP CHEATSHEET
curl HTTP CHEATSHEET
curl HTTP CHEATSHEET
Imported from Notion: curl HTTP CHEATSHEET
updated:: 2026.07.10
Que resuelve
Referencia rapida de curl para probar APIs, depurar HTTP/HTTPS, enviar JSON, trabajar con cabeceras, cookies, autenticacion y proxies.
Uso basico
Peticion GET
curl https://{HOST}/{PATH}
Mostrar cabeceras de respuesta
curl -i https://{HOST}/{PATH}
Solo cabeceras
curl -I https://{HOST}/{PATH}
Seguir redirecciones
curl -L https://{HOST}/{PATH}
Ver detalle de la conexion
curl -v https://{HOST}/{PATH}
Metodos HTTP
POST vacio
curl -X POST https://{HOST}/{PATH}
Enviar JSON
curl -X POST https://{HOST}/{PATH} -H 'Content-Type: application/json' -d '{"key":"value"}'
PUT con JSON
curl -X PUT https://{HOST}/{PATH} -H 'Content-Type: application/json' -d '{"key":"value"}'
DELETE
curl -X DELETE https://{HOST}/{PATH}
Cabeceras
Anadir header
curl -H 'Authorization: Bearer {TOKEN}' https://{HOST}/{PATH}
Cambiar User-Agent
curl -A '{USER_AGENT}' https://{HOST}/{PATH}
Enviar Host header manual
curl -H 'Host: {VHOST}' http://{IP}/
Formularios
Formulario URL-encoded
curl -X POST https://{HOST}/{PATH} -d 'user={USER}' -d 'password={PASSWORD}'
Multipart con archivo
curl -X POST https://{HOST}/{PATH} -F 'file=@{FILE}'
Cookies y sesiones
Guardar cookies
curl -c cookies.txt https://{HOST}/{PATH}
Reutilizar cookies
curl -b cookies.txt https://{HOST}/{PATH}
Enviar cookie manual
curl -H 'Cookie: session={SESSION_ID}' https://{HOST}/{PATH}
Autenticacion
Basic Auth
curl -u '{USER}:{PASSWORD}' https://{HOST}/{PATH}
Bearer token
curl -H 'Authorization: Bearer {TOKEN}' https://{HOST}/{PATH}
API key por header
curl -H 'X-API-Key: {API_KEY}' https://{HOST}/{PATH}
Descargas
Guardar con nombre remoto
curl -O https://{HOST}/{FILE}
Guardar con nombre local
curl -o {OUTPUT_FILE} https://{HOST}/{FILE}
Reintentos
curl --retry 3 --retry-delay 2 -o {OUTPUT_FILE} https://{HOST}/{FILE}
Proxy y Burp
Usar proxy HTTP
curl -x http://127.0.0.1:8080 https://{HOST}/{PATH}
Ignorar validacion TLS en laboratorio
curl -k -x http://127.0.0.1:8080 https://{HOST}/{PATH}
warningUsa
-ksolo en laboratorio o diagnostico puntual. En produccion oculta problemas reales de certificados.
TLS y certificados
Ver negociacion TLS
curl -vI https://{HOST}/
Forzar HTTP/1.1
curl --http1.1 https://{HOST}/{PATH}
Forzar HTTP/2
curl --http2 https://{HOST}/{PATH}
Salida util para scripts
Fallar si HTTP devuelve error
curl -f https://{HOST}/{PATH}
Silencioso pero mostrando errores
curl -fsS https://{HOST}/{PATH}
Imprimir codigo HTTP
curl -s -o /dev/null -w '%{http_code}\n' https://{HOST}/{PATH}
Medir tiempos
curl -s -o /dev/null -w 'dns=%{time_namelookup} connect=%{time_connect} total=%{time_total}\n' https://{HOST}/{PATH}
Variables
| Variable | Descripcion |
|---|---|
{HOST} | Dominio o IP |
{PATH} | Ruta del recurso |
{TOKEN} | Token de autorizacion |
{FILE} | Archivo local o remoto |
{OUTPUT_FILE} | Archivo de salida |
Errores comunes
| Error | Causa probable | Solucion |
|---|---|---|
Could not resolve host | DNS o URL mal formada | Revisa dominio y comillas |
SSL certificate problem | Certificado no confiable | Verifica cadena o usa CA correcta |
Connection refused | Puerto cerrado | Comprueba servicio y firewall |
| Respuesta vacia | Redirect o auth | Prueba -v, -i y -L |
Checklist final
-
Usa
-vpara diagnosticar. -
Usa
-fsSen scripts. -
Guarda cookies si necesitas sesion.
-
Evita
-kfuera de laboratorio.
- EOF -