要发送超过插座一个HTTP请求 [英] Trying to send an HTTP request over sockets
问题描述
我无法发送使用ActionScript 3的Socket()对象一个简单的HTTP请求。我的onConnect听者如下:
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();
}
使用数据包嗅探器,可以看我的要求确实被发送到服务器,但该数据包嗅探器无法识别的协议为HTTP就像它与其他的HTTP服务。当我运行此,服务器只是最终切断了我。我试图连接到其他简单的Apache服务器,只得到一个畸形的请求错误。
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.
我是什么在这里失踪?
推荐答案
您必须刷新之前写另一个\ r \ n来流告诉你发送完头的HTTP服务器。
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.
这篇关于要发送超过插座一个HTTP请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!