mIRC Homepage
Posted By: Fantas socket help - 03/03/07 10:39 PM
i'm trying to check if the file exists, problem is it says the 404 error message like 30 times. Sometimes it says 404 even tho 404 isn't in %temp. The %site and %url and %file are all right %site is like www.site.com %url is like /pics/pic.jpg %file would be pic.jpg so what am i doing wrong? the http:// the webpage put in not me



on *:SOCKOPEN:cnb: {
echo -s *** $sockname was just opened, Retrieving file %file
sockwrite -n $sockname GET / $+ %url HTTP/1.1
sockwrite -n $sockname Host: $+ %site
sockwrite -n $sockname Connection: Keep-Alive
sockwrite $sockname $crlf

}

on *:SOCKCLOSE:cnb: {
echo -s *** $sockname just closed
}

on *:SOCKREAD:cnb: {
sockread %temp
if (404 isin %temp) msg $chan %file not found
if (302 isin %temp) msg $chan %file has been moved
if (301 isin %temp) msg $chan %file moved permanently
}
Posted By: Damsulegna Re: socket help - 03/03/07 10:58 PM
Try it with simple domain name
sockwrite -n $sockname Host: site.com


try not to use Host: $+ %site as the $+ will make it Host:%Site surely

Also is %url prefixed with /
if so wouldnt GET / $+ %url return //pics/pic.jpg

just a few thoughts.
Posted By: genius_at_work Re: socket help - 04/03/07 12:40 AM
For debugging purposes, you could put an echo line to display the contents of %temp

[/code]
on *:SOCKREAD:cnb:{
var %temp
sockread %temp
echo -s > %temp
;...
}
[/code]

You will be able to see each line that is /sockread.

Also, if (404 isin %temp) will match on ANY instance of '404' within the page source.

For mIRC sockets, it's usually better to use HTTP/1.0 instead of HTTP/1.1

-genius_at_work

-genius_at_work
© mIRC Discussion Forums