Thursday, January 6, 2011

Simple request to check web server response.

Sometimes I need to get response not only from web client. For example, now I am in Australia and I suppose that avito.ru blocked all networks outside of Russia to avoid indexing by servers abroad. So I need to get return code. The best way, as  I think, is to call telnet:

Here is a simple bash script(GET.sh): 
#!/bin/bash

echo 'GET / HTTP/1.1';echo 'Host: '$1;echo;echo; sleep 2 ) | telnet $1 $2

How to call it:
#./GET.sh www.avito.ru 80

Trying 81.177.35.167...
Connected to www.avito.ru.
Escape character is '^]'.
HTTP/1.1 403 Forbidden
Server: nginx
Date: Thu, 06 Jan 2011 12:15:03 GMT
Content-Type: text/html
Content-Length: 162
Connection: keep-alive

<html>
<head><title>403 Forbidden</title></head>
<body bgcolor="white">
<center><h1>403 Forbidden</h1></center>
<hr><center>nginx</center>
</body>
</html>
Connection closed by foreign host.