Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

404 not found in telnet, works fine in browser

i am having a very irritating problem, when i open a url ( http://celebs.widewallpapers.net/md/a/adriana-lima/1440/Adriana-Lima-1440x900-002.jpg ) in browser, it works fine.. but when i try to access it by telnet on bash, i get 404 not found!!

my exact terminal:

$ telnet celebs.widewallpapers.net 80

HEAD /md/a/adriana-lima/1440/Adriana-Lima-1440x900-002.jpg HTTP/1.0 [enter] [enter]

HTTP/1.1 404 Not Found

Server: nginx

Date: Sun, 23 May 2010 21:36:05 GMT

Content-Type: text/html; charset=windows-1251

Content-Length: 166 Connection: close

please help me with this as i m trying to make a C batch-downloader, which is almost working as same as the telnet.

like image 274
Viranch Mehta Avatar asked Dec 29 '22 16:12

Viranch Mehta


1 Answers

You aren't passing a host header. As per HTTP/1.1 you need to tell the web server which virtual host you are expecting to talk to. And 99% of servers today will only talk HTTP/1.1 even if you specify HTTP/1.0 in the request.

jb@apto % telnet celebs.widewallpapers.net 80
...
HEAD /md/a/adriana-lima/1440/Adriana-Lima-1440x900-002.jpg HTTP/1.1
Host: celebs.widewallpapers.net

HTTP/1.1 200 OK
Server: nginx
Date: Sun, 23 May 2010 22:08:36 GMT
Content-Type: image/jpeg
Connection: close
Last-Modified: Sun, 27 Apr 2008 14:30:17 GMT
ETag: "4784e0-264b0-48148df9"
Accept-Ranges: bytes
Content-Length: 156848

Connection closed by foreign host.
like image 195
Jakob Borg Avatar answered Jan 02 '23 23:01

Jakob Borg