mIRC Home    About    Download    Register    News    Help

Print Thread
Confused (Sock Problem) #168805 14/01/07 09:02 PM
Joined: Dec 2002
Posts: 22
S
Synister Offline OP
Ameglian cow
OP Offline
Ameglian cow
S
Joined: Dec 2002
Posts: 22
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.




Re: Confused (Sock Problem) [Re: Synister] #168806 14/01/07 09:35 PM
Joined: Jun 2004
Posts: 14
B
Byte187 Offline
Pikka bird
Offline
Pikka bird
B
Joined: Jun 2004
Posts: 14
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
} 

Re: Confused (Sock Problem) [Re: Byte187] #168807 14/01/07 09:38 PM
Joined: Dec 2002
Posts: 22
S
Synister Offline OP
Ameglian cow
OP Offline
Ameglian cow
S
Joined: Dec 2002
Posts: 22
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




Re: Confused (Sock Problem) [Re: Synister] #168808 14/01/07 09:43 PM
Joined: Jun 2004
Posts: 14
B
Byte187 Offline
Pikka bird
Offline
Pikka bird
B
Joined: Jun 2004
Posts: 14
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.

Re: Confused (Sock Problem) [Re: Byte187] #168810 14/01/07 09:49 PM
Joined: Dec 2002
Posts: 22
S
Synister Offline OP
Ameglian cow
OP Offline
Ameglian cow
S
Joined: Dec 2002
Posts: 22
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?




Re: Confused (Sock Problem) [Re: Synister] #168812 14/01/07 10:00 PM
Joined: Jun 2004
Posts: 14
B
Byte187 Offline
Pikka bird
Offline
Pikka bird
B
Joined: Jun 2004
Posts: 14
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

Re: Confused (Sock Problem) [Re: Byte187] #168813 14/01/07 10:05 PM
Joined: Dec 2002
Posts: 22
S
Synister Offline OP
Ameglian cow
OP Offline
Ameglian cow
S
Joined: Dec 2002
Posts: 22
got it thanks