| Blockland Forums > Modification Help |
| HTTPObject |
| << < (2/3) > >> |
| Bauklotz:
--- Code: ---new TCPObject(cucumber) { host = "mysite.com:80"; }; function cucumber::sendRequest(%this, %request) { %this.request = %request SPC "HTTP/1.0\r\nHost:" SPC getSubStr(%this.host, 0, strPos(%this.host, ":")) @ "\r\nConnection: close\r\n\r\n"; %this.connect(%this.host); } function cucumber::onConnected(%this) { if(strLen(%req = %this.request) < 1) { %this.disconnect(); return; } %this.request = ""; %this.send(%req); } function cucumber::onLine(%this, %line) { // stuff } function cucumber::onDisconnect(%this) { // stuff } --- End code --- cucumber.sendRequest("GET /bla.php?var1=please&var2=work"); |
| Destiny/Zack0Wack0:
Client networking with TCPObject function TCPObject::onDNSResolved(%this) function TCPObject::onDNSFailed(%this) function TCPObject::onConnected(%this) function TCPObject::onConnectFailed(%this) function TCPObject::onDisconnect(%this) function TCPObject::onLine(%this,%line) TCPObject.connect("host:port"); TCPObject.send("packet"); Simple HTTP request --- Code: ---$url = "www.google.com"; $port = 80; $file = "/search"; $args = "?q=dog"; new TCPObject(Google); function googleIt(%query) { $args = "?q=" @ urlEnc(%query); Google.connect($url @ ":" @ $port); } function Google::onConnected(%this) { %this.send("GET " @ $file @ $args @ " HTTP/1.0\r\nHost: " @ $url @ "\r\nUser-Agent: Torque/1.0\r\n\r\n"); } function Google::onLine(%this,%line) { echo("RECEIVED LINE: " @ %line); } --- End code --- |
| cucumberdude:
Thanks guys, got it working. Only problem is I get some gibberish about the server before the content. --- Code: ---HTTP/1.1 200 OK Date: Sat, 12 Mar 2011 05:45:33 GMT Server: Apache X-Powered-By: PHP/5.2.16 Connection: close Content-Type: text/html --- End code --- How do I get rid of that? |
| Iban:
--- Quote from: cucumberdude on March 12, 2011, 01:37:52 AM ---Thanks guys, got it working. Only problem is I get some gibberish about the server before the content. --- Code: ---HTTP/1.1 200 OK Date: Sat, 12 Mar 2011 05:45:33 GMT Server: Apache X-Powered-By: PHP/5.2.16 Connection: close Content-Type: text/html --- End code --- How do I get rid of that? --- End quote --- Both Ephialtes and Badspot do this. HTTP/1.1 200 OK Date: Sat, 12 Mar 2011 05:45:33 GMT Server: Apache X-Powered-By: PHP/5.2.16 Connection: close Content-Type: text/html START information/tinformation/tinformation/tinformation information/tinformation/tinformation/tinformation information/tinformation/tinformation/tinformation information/tinformation/tinformation/tinformation information/tinformation/tinformation/tinformation information/tinformation/tinformation/tinformation information/tinformation/tinformation/tinformation information/tinformation/tinformation/tinformation information/tinformation/tinformation/tinformation information/tinformation/tinformation/tinformation information/tinformation/tinformation/tinformation END The only record what's between START and END. view-source:http://master2.blockland.us/ |
| cucumberdude:
Oh duh, just tailor PHP output. Thanks. |
| Navigation |
| Message Index |
| Next page |
| Previous page |