Visualizar cabeceras HTTP de un servidor remoto

Hoy me ha llamado un amigo preguntándome como saber si una petición que estaba haciendo a un servidor era correcta o no.

Lo primero en lo que pensé fue en usar curl, pero luego me quedé pensando en otras formas de hacerlo, desde wget hasta netcat. Sin ir a opciones raras, aquí van 3 formas de obtener las cabeceras HTTP de respuesta:

Mirar cabeceras HTTP con Curl (La primera porque es la que suelo usar) Incluyo la opción de seguir las redirecciones indicadas por el servidor.

curl -I http://m
javi@musashi:~$ curl -I -L http://www.slashdot.org
HTTP/1.1 301 Moved Permanently (Nos indican una redirección al host del campo posterior «Location»)
Server: Apache/2.2.3 (CentOS) Indica el servidor que está despachando la petición. Puede ser real o estar manipulado.
Location: http://slashdot.org/ Aquí es a donde nos mandan.
Content-Type: text/html; charset=iso-8859-1
Content-Length: 309 Tamaño de la respuesta
Date: Sat, 08 Jun 2013 13:03:19 GMT
X-Varnish: 1849026558 1849026381 Usan varnish cache. Bien :)
Age: 35 Cuantos segundos tiene el contenido servido.
Connection: keep-alive Usan keepalive para minimizar conexiones
Vary: Accept-Encoding Permiten compresión gzip si la soporta el cliente

HTTP/1.1 200 OK La petición ya no es redirigida y es correcta.
Server: Apache/2.2.3 (CentOS)
SLASH_LOG_DATA: shtml
Cache-Control: no-cache
Pragma: no-cache
X-XRDS-Location: http://slashdot.org/slashdot.xrds
Content-Type: text/html; charset=utf-8
Content-Length: 112918
Date: Sat, 08 Jun 2013 13:03:19 GMT
X-Varnish: 1898815004 1898814944
Age: 13
Connection: keep-alive
Vary: Accept-Encoding

Otras formas de ver las cabeceras son:

Mirar cabeceras HTTP con Wget
wget -S http://url

Mirar cabeceras HTTP con Telnet

javi@musashi:~$ telnet
telnet> open slashdot.org 80
Trying 216.34.181.45...
Connected to slashdot.org.
Escape character is '^]'.
GET / HTTP/1.1
Host: www.slashdot.org

HTTP/1.1 301 Moved Permanently
Server: Apache/2.2.3 (CentOS)
Location: http://slashdot.org/
Content-Type: text/html; charset=iso-8859-1
Content-Length: 309
Date: Sat, 08 Jun 2013 13:09:18 GMT
X-Varnish: 1793797545 1793797529
Age: 4
Connection: keep-alive
Vary: Accept-Encoding



301 Moved Permanently

Moved Permanently

The document has moved here.


Apache/2.2.3 (CentOS) Server at www.slashdot.org Port 80
Connection closed by foreign host.

Este articulo puede contener enlaces de afiliación

Deja una respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *