Adobe Flex 中的 HTTP URLRequest
我正在尝试在 Adobe Flex 中创建一个简单的 HTTP URLReqest,大致代码如下:
var requestSender:URLLoader = new URLLoader();
var urlRequest :URLRequest = new URLRequest("http://localhost:8888");
var msg:String = "data=blah";
urlRequest.data = msg;
urlRequest.contentType = "application/x-www-form-urlencoded";
urlRequest.method = URLRequestMethod.POST;
这会产生接近于:
POST / HTTP/1.1
Referer: app:/PersonSearch.swf
Accept: text/xml, application/xml, application/xhtml+xml, ...
x-flash-version: 10,1,85,3
Content-Type: application/x-www-form-urlencoded
Content-Length: 102
Accept-Encoding: gzip,deflate
User-Agent: Mozilla/5.0 (Windows; U; en-US) ...
Host: 127.0.0.1:8888
Connection: Keep-Alive
data=blah
我真正想要的是:
POST / HTTP/1.1
Content-Type:application/x-www-form-urlencoded
Connection:close
Via:MDS_777
Accept:*/ *
Host:localhost:8888
Content-Length:104
data=blah
任何人都知道我如何删除字段例如接受编码,添加“Via”等字段并将连接设置为“关闭”?
另外,我们如何从 HTTP 请求中获取响应?
谢谢 菲尔
Im trying to make a simple HTTP URLReqest in Adobe Flex, heres the code roughly:
var requestSender:URLLoader = new URLLoader();
var urlRequest :URLRequest = new URLRequest("http://localhost:8888");
var msg:String = "data=blah";
urlRequest.data = msg;
urlRequest.contentType = "application/x-www-form-urlencoded";
urlRequest.method = URLRequestMethod.POST;
This produces something close to:
POST / HTTP/1.1
Referer: app:/PersonSearch.swf
Accept: text/xml, application/xml, application/xhtml+xml, ...
x-flash-version: 10,1,85,3
Content-Type: application/x-www-form-urlencoded
Content-Length: 102
Accept-Encoding: gzip,deflate
User-Agent: Mozilla/5.0 (Windows; U; en-US) ...
Host: 127.0.0.1:8888
Connection: Keep-Alive
data=blah
What I really want is:
POST / HTTP/1.1
Content-Type:application/x-www-form-urlencoded
Connection:close
Via:MDS_777
Accept:*/ *
Host:localhost:8888
Content-Length:104
data=blah
Anyone know how I remove the fields like Accept-Encoding, add fields like "Via" and set Connection to "close"?
Also how do we get the responce from the HTTP request?
Thanks
Phil
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Flash Player 不允许您通过 ActionScript 更改 Accept-Encoding 或 Via 标头。如果您尝试这样做,您将收到如下消息:
如果您使用 URL 变量,您可以尝试通过执行以下操作来简化代码:
要获取响应,您必须侦听“requestSender”上的
Event.COMPLETE
:The Flash Player doesn't allow you to change the Accept-Encoding or Via headers through ActionScript. If you try do that you will get a message like this one:
If you are using URL variables you can try to simplify your code by doing this:
To get the response you will have to listen for the
Event.COMPLETE
on the "requestSender":