I’m having trouble sending out a simple HTTP request using Actionscript 3’s Socket() object. My onConnect listener is below:
function sConnect(e:Event):void { trace('connected'); s.writeUTFBytes('GET /outernet/client/rss/reddit-feeds HTTP/1.1\r\n'); s.writeUTFBytes('Host: 208.43.71.50:8080\r\n'); s.writeUTFBytes('Connection: Keep-alive\r\n'); s.flush(); }
Using a packet sniffer, I can see the request does indeed get sent to the server, but the packet sniffer doesn’t identify the protocol as HTTP like it does with other HTTP services. When I run this, the server just eventually disconnects me. I have tried to connect to other simple Apache Servers and just get a malformed request error.
What am I missing here?
You have to write another ‘\r\n’ to the stream before the flush to tell the HTTP server that you’re finished sending the headers.