mIRC Home    About    Download    Register    News    Help

Print Thread
sockread, getting headers only #210529 18/03/09 11:47 PM
Joined: Feb 2007
Posts: 234
M
MTec007 Offline OP
Fjord artisan
OP Offline
Fjord artisan
M
Joined: Feb 2007
Posts: 234
i cannot get mirc to receive the content of this page, i only get the header. what am i doing wrong?

Code:
on 1:sockopen:IOS:{
  sockwrite -n $sockname GET /IOS/ $+ %IOS.request HTTP/1.0
  sockwrite -n $sockname User-Agent: IOS 1.0/mIRC $version
  sockwrite -n $sockname Host: www.host.com $+ $crlf $+ $crlf 
}
on 1:sockread:IOS:{
  if ($sockerr) { echo -a IOS Socket Error. | halt }
  else {
    sockread %temp
    echo -a : %temp
  }
  unset %IOS.request
}

Re: sockread, getting headers only [Re: MTec007] #210530 18/03/09 11:58 PM
Joined: Feb 2005
Posts: 342
R
Rand Offline
Fjord artisan
Offline
Fjord artisan
R
Joined: Feb 2005
Posts: 342
I usually just do:
Code:
on *:sockopen:name:{
  var %swrite = sockwrite -n $sockname

  %swrite GET /path/to/page.php HTTP/1.0
  %swrite Host: sub.domain.com
  %swrite User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)
  %swrite
}

on *:sockread:name:{
  if ($sockerr) { return }
  var %s | sockread %s

  while ($sockbr) {
    echo -a : %s
    sockread %s
  }
}

Re: sockread, getting headers only [Re: Rand] #210531 19/03/09 12:03 AM
Joined: Feb 2007
Posts: 234
M
MTec007 Offline OP
Fjord artisan
OP Offline
Fjord artisan
M
Joined: Feb 2007
Posts: 234
that is just returning the header

Code:
: HTTP/1.0 200 OK
: Date: Thu, 19 Mar 2009 00:01:28 GMT
: Server: Apache/2.2.11 (Unix) mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635 PHP/5.2.8 mod_perl/2.0.4 Perl/v5.8.8
: X-Powered-By: PHP/5.2.8
: Cache-Control: max-age=1
: Expires: Thu, 19 Mar 2009 00:01:29 GMT
: Vary: Accept-Encoding,User-Agent
: Content-Length: 2
: Content-Type: text/html
: X-Cache: MISS from sv27.byethost27.org
: X-Cache-Lookup: MISS from sv27.byethost27.org:80
: Via: 1.1 sv27.byethost27.org:80 (squid/2.7.STABLE6-20090214)
: Connection: close
:

Re: sockread, getting headers only [Re: MTec007] #210535 19/03/09 01:10 AM
Joined: Jan 2007
Posts: 1,156
D
DJ_Sol Offline
Hoopy frood
Offline
Hoopy frood
D
Joined: Jan 2007
Posts: 1,156
Content-Length: 2
: Content-Type: text/html


A 2 byte text file? Try accessing a file with some data in it.

Re: sockread, getting headers only [Re: DJ_Sol] #210549 19/03/09 07:32 AM
Joined: Feb 2007
Posts: 234
M
MTec007 Offline OP
Fjord artisan
OP Offline
Fjord artisan
M
Joined: Feb 2007
Posts: 234
i need that message. its a status message for the results of the GET request. i gotta have it.

Re: sockread, getting headers only [Re: MTec007] #210568 20/03/09 04:15 AM
Joined: Feb 2007
Posts: 234
M
MTec007 Offline OP
Fjord artisan
OP Offline
Fjord artisan
M
Joined: Feb 2007
Posts: 234
by writeing the entire thing to a file i can get what i want but now i need to find out how to strip or remove the header from the text file. does any one have an idea for that?

Re: sockread, getting headers only [Re: MTec007] #210570 20/03/09 04:36 AM
Joined: Oct 2005
Posts: 1,741
G
genius_at_work Offline
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
Try this:

Code:

alias IOS {
  var %host = www.google.ca
  var %req = index.html
  ;
  if ($sock(IOS)) sockclose IOS
  sockopen IOS %host 80
  sockmark IOS %host %req
}

on *:SOCKOPEN:IOS:{
  sockwrite -n IOS GET /IOS/ $+ $gettok($sock(IOS).mark,2,32) HTTP/1.0
  sockwrite -n IOS Host: $gettok($sock(IOS).mark,1,32)
  sockwrite -n IOS $crlf
  sockmark IOS $false
}
on *:SOCKREAD:IOS:{
  var %s
  sockread %s
  if ($sock(IOS).mark == $false) {
    if (%s == $null) sockmark IOS $true
    return
  }   
  else {
    echo -a $+(4,>,3,%s)
  } 
}



-genius_at_work

Re: sockread, getting headers only [Re: genius_at_work] #210571 20/03/09 05:14 AM
Joined: Feb 2007
Posts: 234
M
MTec007 Offline OP
Fjord artisan
OP Offline
Fjord artisan
M
Joined: Feb 2007
Posts: 234
thanks:)