mIRC Homepage
Posted By: Synister Confused (Sock Problem) - 14/01/07 09:02 PM
Ok this is what I have.

Code:
alias hread {
  sockopen hread www.maxoctane.net 80
}

on *:sockopen:hread:{
  sockwrite -nt hread GET /humveeupdate.txt
  sockwrite -t hread $crlf
}

on *:sockread:hread:{
  if ($sockerr) return
  sockread 942 &temp
  echo -s -------------------------------------------------------
  echo -s Getting Update Information, Please Wait.
  echo -s -------------------------------------------------------
  echo -s  Update Information:
  echo -s $bvar(&temp,1-).text
} 


And when triggered I get

-------------------------------------------------------
Getting Update Information, Please Wait.
-------------------------------------------------------
Update Information:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL /humveeupdate.txt was not found on this server.</p>
<hr>
<address>Apache/2.0.54 (Fedora) Server at default Port 80</address>
</body></html>



However the file.
www.maxoctane.net/humveeupdate.txt does exist and i can go to it w/ my browser.

am I doing something wrong? Any help is greatly appreciated.
Posted By: Byte187 Re: Confused (Sock Problem) - 14/01/07 09:35 PM
The server you're connecting to uses name based hosting. Use HTTP/1.1 and specify the host name in your request headers.
Code:
alias hread {
  sockopen hread www.maxoctane.net 80
}

on *:sockopen:hread:{
  sockwrite -n hread GET /humveeupdate.txt HTTP/1.1
  sockwrite -n hread Host: www.maxoctane.net
  sockwrite -n hread User-Agent: mIRC $version
  sockwrite -n hread
}

on *:sockread:hread:{
  if ($sockerr) return
  sockread 942 &temp
  echo -s -------------------------------------------------------
  echo -s Getting Update Information, Please Wait.
  echo -s -------------------------------------------------------
  echo -s  Update Information:
  echo -s $bvar(&temp,1-).text
} 
Posted By: Synister Re: Confused (Sock Problem) - 14/01/07 09:38 PM
Now i get this as a reply


-------------------------------------------------------
Getting Update Information, Please Wait.
-------------------------------------------------------
Update Information:
HTTP/1.1 200 OK
Date: Sun, 14 Jan 2007 21:36:43 GMT
Server: Apache/2.0.54 (Fedora)
Last-Modified: Sun, 14 Jan 2007 21:14:50 GMT
ETag: "4beead-21-9e8a6680"
Accept-Ranges: bytes
Content-Length: 33
Connection: close
Content-Type: text/plain

NO UPDATES AVAILABLE AT THIS TIME



How can I remove

HTTP/1.1 200 OK
Date: Sun, 14 Jan 2007 21:36:43 GMT
Server: Apache/2.0.54 (Fedora)
Last-Modified: Sun, 14 Jan 2007 21:14:50 GMT
ETag: "4beead-21-9e8a6680"
Accept-Ranges: bytes
Content-Length: 33
Connection: close
Content-Type: text/plain
Posted By: Byte187 Re: Confused (Sock Problem) - 14/01/07 09:43 PM
The first empty line indicates the end of the http header. Discard everything up to the first empty line and then display anything that follows.
Posted By: Synister Re: Confused (Sock Problem) - 14/01/07 09:49 PM
Originally Posted By: Byte187
The first empty line indicates the end of the http header. Discard everything up to the first empty line and then display anything that follows.



Now Im really Lost.. What am I discarding?
Posted By: Byte187 Re: Confused (Sock Problem) - 14/01/07 10:00 PM
You don't want to display the http header returned by the server. So discard it and only display the data you're looking for.

The header and the data are seperated by an empty line.

1. HTTP headers
2. Empty line
3. Data

HTTP/1.1 200 OK
Date: Sun, 14 Jan 2007 21:36:43 GMT
Server: Apache/2.0.54 (Fedora)
Last-Modified: Sun, 14 Jan 2007 21:14:50 GMT
ETag: "4beead-21-9e8a6680"
Accept-Ranges: bytes
Content-Length: 33
Connection: close
Content-Type: text/plain

<-- notice this empty line? -->
NO UPDATES AVAILABLE AT THIS TIME
Posted By: Synister Re: Confused (Sock Problem) - 14/01/07 10:05 PM
got it thanks
© mIRC Discussion Forums