xumarhu.net xumarhu.net biblioteca
Principal > Biblioteca > Manuales de Comandos > Comandos para enviar métodos HTTP

Comandos para enviar métodos HTTP utilizando telnet

A continuación se muestran algunos ejemplos para enviar los diferentes métodos de HTTP que se invocan desde un cliente a un servidor web por medio del puerto 80 utilizando telnet para poder hacer la conexión (requiere tener habilitado el telnet).


método "OPTIONS": Muestra los metodos disponibles que tiene habilitados un servidor Web.

NOTA: Lo que está en negrita es lo que se teclea dentro de la consola de la conexión telnet, lo que sigue a continuación es lo que contesta el servidor web (aplica a todos los ejemplos que vienen a continuación).

EJEMPLO 1

rogelio@rogelio-laptop:/opt/lampp/htdocs$ telnet www.xumarhu.net 80
Trying 75.127.85.47...
Connected to xumarhu.net.
Escape character is '^]'.
OPTIONS / HTTP/1.1
Host: www.xumarhu.net

HTTP/1.1 200 OK
Date: Thu, 14 Mar 2013 03:12:59 GMT
Server: Apache/2.2.22 (Unix) mod_ssl/2.2.22 OpenSSL/0.9.8e-fips-rhel5 mod_bwlimited/1.4
Allow: GET,HEAD,POST,OPTIONS,TRACE
Content-Length: 0
Content-Type: text/html

Connection closed by foreign host.
rogelio@rogelio-laptop:/opt/lampp/htdocs$


método "HEAD": Invoca la cabecera de un servidor web.

EJEMPLO 1

rogelio@rogelio-laptop:/opt/lampp/htdocs$ telnet 192.168.1.70 80Trying 192.168.1.70...
Connected to 192.168.1.70.
Escape character is '^]'.
HEAD /hola.htm HTTP/1.1
Host: 192.168.1.70

HTTP/1.1 200 OK
Date: Thu, 14 Mar 2013 03:04:33 GMT
Server: Apache/2.2.14 (Unix) DAV/2 mod_ssl/2.2.14 OpenSSL/0.9.8l PHP/5.3.1 mod_apreq2-20090110/2.7.1 mod_perl/2.0.4 Perl/v5.10.1
Accept-Ranges: bytes
Content-Length: 45
Content-Type: text/html

Connection closed by foreign host.
rogelio@rogelio-laptop:/opt/lampp/htdocs$

EJEMPLO 2

rogelio@rogelio-laptop:/opt/lampp/htdocs$ telnet www.xumarhu.net 80
Trying 75.127.85.47...
Connected to www.xumarhu.net.
Escape character is '^]'.
HEAD / HTTP/1.1
Host: www.xumarhu.net

HTTP/1.1 200 OK
Date: Thu, 14 Mar 2013 03:17:29 GMT
Server: Apache/2.2.22 (Unix) mod_ssl/2.2.22 OpenSSL/0.9.8e-fips-rhel5 mod_bwlimited/1.4
Last-Modified: Tue, 12 Mar 2013 17:54:02 GMT
ETag: "1ad30241-cc9-4d7bdf986e280"
Accept-Ranges: bytes
Content-Length: 3273
Content-Type: text/html

Connection closed by foreign host.
rogelio@rogelio-laptop:/opt/lampp/htdocs$



método "GET": Invoca la cabecera de un servidor web y descarga la pagina web que se especifique

EJEMPLO 1

rogelio@rogelio-laptop:~$ telnet 192.168.1.70 80
Trying 192.168.1.70...
Connected to 192.168.1.70.
Escape character is '^]'.
GET /hola.htm HTTP/1.1
Host: 192.168.1.70

HTTP/1.1 200 OK
Date: Thu, 14 Mar 2013 02:36:16 GMT
Server: Apache/2.2.14 (Unix) DAV/2 mod_ssl/2.2.14 OpenSSL/0.9.8l PHP/5.3.1 mod_apreq2-20090110/2.7.1 mod_perl/2.0.4 Perl/v5.10.1
Accept-Ranges: bytes
Content-Length: 45
Content-Type: text/html

Hola Mundo!!! Connection closed by foreign host.
rogelio@rogelio-laptop:~$

EJEMPLO 2

rogelio@rogelio-laptop:/opt/lampp/htdocs$ telnet www.xumarhu.net 80
Trying 75.127.85.47...
Connected to www.xumarhu.net.
Escape character is '^]'.
GET /index.html HTTP/1.1
Host: www.xumarhu.net

HTTP/1.1 200 OK
Date: Thu, 14 Mar 2013 03:19:13 GMT
Server: Apache/2.2.22 (Unix) mod_ssl/2.2.22 OpenSSL/0.9.8e-fips-rhel5 mod_bwlimited/1.4
Last-Modified: Tue, 12 Mar 2013 17:54:02 GMT
ETag: "1ad30241-cc9-4d7bdf986e280"
Accept-Ranges: bytes
Content-Length: 3273
Content-Type: text/html

<!DOCTYPE html>

<!-- xumarhu.net - Rogelio Ferreira Escutia -->

<html>
<head>
<meta charset="utf-8" />
<title>xumarhu.net
<meta name="keywords" content="xumarhu web internet movil" />
<meta name="description" content="Portal de Tecnologia desarrollado por Rogelio Ferreira Escutia" />
<meta name="Author" content="Rogelio Ferreira Escutia" />
<link rel="stylesheet" type="text/css" href="xum_hoja.css" />
</head>

<body> <div class="centrar_pagina">
<a href="index.html">
<img class="imagen" src="xum_bane.gif" alt="xumarhu.net" />
</a>
<div class="texto_mensaje">
"xumarhu" es una palabra en purépecha que significa "nube", y en este sitio encontrarás información sobre Tecnologías Web, Internet y Cómputo Móvil
</div>
<img class="imagen" src="xum_line.gif" alt="línea" />
<table>
<tr>
<td>
<img class="imagen" src="xum_0001.jpg" alt="xumarhu.net" />
<div class="texto_titulo">Morelia
</div>
<div class="texto_nota">
<br />Visita de alumnos de la carrera de Informática del ITM al Rancho Ecológico La Planta, 6 de marzo del 2009
</div>
<a href="">
...

</td>
<td>
<a href="cur_inic.htm">
<img class="imagen" src="xum_curs.jpg" alt="Cursos" />
<img class="imagen" src="xum_9999.gif" alt="xumarhu.net" />
<img class="imagen" src="xum_9999.gif" alt="xumarhu.net" />
<img class="imagen" src="xum_9999.gif" alt="xumarhu.net" />
</td>
<td>
<a href="bib_inic.htm">
<img class="imagen" src="xum_bibl.jpg" alt="Biblioteca de apuntes" />
<img class="imagen" src="xum_9999.gif" alt="xumarhu.net" />
<img class="imagen" src="xum_9999.gif" alt="xumarhu.net" />
<a href="http://twitter.com/#!/rogeplus">
<img class="imagen" src="xum_twit.jpg" alt="sigueme en twitter http://twitter.com/rogeplus" />
</a>
</td>
<td>
<a href="rfe_inic.htm">
<img class="imagen" src="xum_mipa.jpg" alt="Página personal de Rogelio Ferreira Escutia" />
</a>
<img class="imagen" src="xum_9999.gif" alt="xumarhu.net" />
<img class="imagen" src="xum_9999.gif" alt="xumarhu.net" />
<a href="http://www.facebook.com/groups/xumarhu.net/">
<img class="imagen" src="xum_face.jpg" alt="grupo xumarhu.net en Facebook" />
</a>
</td>
<td>
<a href="cid_inic.htm">
<img class="imagen" src="xum_9999.gif" alt="CIDAWI" />
</a>
<img class="imagen" src="xum_9999.gif" alt="xumarhu.net" />
<img class="imagen" src="xum_9999.gif" alt="xumarhu.net" />
<img class="imagen" src="xum_gmai.jpg" alt="escríbeme a mi cuenta de correo" />
</td>
</tr>
</table>
<img class="imagen" src="xum_line.gif" alt="línea" />
<div class="texto_pie_pagina">Sitios Espejo:
<a href="http://www.xumarhu.net/">http://www.xumarhu.net/ - <a href="http://antares.itmorelia.edu.mx/~kaos/">http://antares.itmorelia.edu.mx/~kaos/ - <a href="http://dsc.itmorelia.edu.mx/~rferreir/">http://dsc.itmorelia.edu.mx/~rferreir/Portal de Tecnología desarrollado por: Rogelio Ferreira Escutia
Ultima Actualización: Martes 12 de marzo del 2013
</div>
</div>
</body>
</html>

Connection closed by foreign host.
rogelio@rogelio-laptop:/opt/lampp/htdocs$



método "POST": Envia datos a una pagina web de un servidor, como si fuera un formulario.

EJEMPLO 1:

rogelio@rogelio-laptop:/opt/lampp/htdocs$ telnet 192.168.1.70 80
Trying 192.168.1.70...
Connected to 192.168.1.70.
Escape character is '^]'.
POST /php_tiendita_registro/tie_regi.php HTTP/1.0
Host: 192.168.1.70
Referer: http://192.168.1.70/php_tiendita_registro/tie_regi.php
Content-Type: application/x-www-form-urlencoded
Content-Length: 51
Connection: close

nombre=juan&login=jon&direccion=centro&telefono=123
HTTP/1.1 200 OK
Date: Thu, 14 Mar 2013 03:54:31 GMT
Server: Apache/2.2.14 (Unix) DAV/2 mod_ssl/2.2.14 OpenSSL/0.9.8l PHP/5.3.1 mod_apreq2-20090110/2.7.1 mod_perl/2.0.4 Perl/v5.10.1
X-Powered-By: PHP/5.3.1
Content-Length: 463
Connection: close
Content-Type: text/html

<!--

tie_regi.php

Registra un cliente en la base de datos
Para crear la base y la tabla se requiere el script: tiendita_registro.sql
Rogelio Ferreira Escutia - septiembre 2010

-->

<!DOCTYPE html>

<html>
<head>
<title>Tiendita PHP Registro > Registrarse
<meta charset="utf-8" />
</head>

<body>
<br />INSERT INTO clientes (nombre, login, direccion, telefono) values ('juan', 'jon', 'centro', '123')
Cliente Registrado!!!
</html>

Connection closed by foreign host.
rogelio@rogelio-laptop:/opt/lampp/htdocs$

Donde el codigo que recibe los datos (tie_regi.php) es:

Tiendita PHP Registro > Registrarse ERROR: Imposible establecer conexión con el servidor"; exit; } if (!mysql_select_db("tiendita_registro",$conexion)) echo "

Error al seleccionar la base de datos

\n"; import_request_variables('p','frm_'); $sql = "INSERT INTO clientes (nombre, login, direccion, telefono) values ('$frm_nombre', '$frm_login', '$frm_direccion', '$frm_telefono')"; echo "
$sql
Cliente Registrado!!!"; mysql_query ($sql,$conexion); ?> y la estructura de la base de datos es:

--
-- tiendita_registro.sql
--
-- Tiendita - Registrar clientes en la base de datos
--

create database tiendita_registro;
use tiendita_registro;
create table clientes (nombre text, login text, direccion text, telefono text);



método "TRACE": Muestra lo que recibe el servidor web por parte del cliente.

EJEMPLO 1

rogelio@rogelio-laptop:/opt/lampp/htdocs$ telnet www.xumarhu.net 80
Trying 75.127.85.47...
Connected to xumarhu.net.
Escape character is '^]'.
TRACE / HTTP/1.1
Host: www.xumarhu.net

HTTP/1.1 200 OK
Date: Thu, 14 Mar 2013 03:36:49 GMT
Server: Apache/2.2.22 (Unix) mod_ssl/2.2.22 OpenSSL/0.9.8e-fips-rhel5 mod_bwlimited/1.4
Transfer-Encoding: chunked
Content-Type: message/http

2b
TRACE / HTTP/1.1
Host: www.xumarhu.net


0

Connection closed by foreign host.
rogelio@rogelio-laptop:/opt/lampp/htdocs$

EJEMPLO 2

rogelio@rogelio-laptop:/opt/lampp/htdocs$ telnet 192.168.1.70 80
Trying 192.168.1.70...
Connected to 192.168.1.70.
Escape character is '^]'.
TRACE /hola.htm HTTP/1.1
Host: 192.168.1.70

HTTP/1.1 200 OK
Date: Thu, 14 Mar 2013 03:40:05 GMT
Server: Apache/2.2.14 (Unix) DAV/2 mod_ssl/2.2.14 OpenSSL/0.9.8l PHP/5.3.1 mod_apreq2-20090110/2.7.1 mod_perl/2.0.4 Perl/v5.10.1
Transfer-Encoding: chunked
Content-Type: message/http

30
TRACE /hola.htm HTTP/1.1
Host: 192.168.1.70


0

Connection closed by foreign host.
rogelio@rogelio-laptop:/opt/lampp/htdocs$

Principal > Biblioteca > Manuales de Comandos > Comandos para enviar métodos HTTP
Portal de Tecnología desarrollado por: Rogelio Ferreira Escutia
Valid CSS Valid XHTML 5