Flash 套接字 HTTP-POST 示例
本文提供了使用 flash.net.Socket 类连接到套接字的示例:
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/Socket.html
底部的示例显示了如何使用HTTP-GET 请求。
我需要使用 HTTP-POST 请求。
额外奖励:这适用于 HTTPS 端口 443 吗?
This article provides an example of using the flash.net.Socket class to connect to a socket:
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/Socket.html
The example at the bottom shows how to use an HTTP-GET request.
I need to use an HTTP-POST request.
Bonus: Does this work with HTTPS port 443?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Socket 不是适合这项工作的正确类。套接字用于处理原始 TCP 数据连接。例如,您可以使用 Socket 与使用专有通信协议的自定义服务器组件集成。
相反,请使用 URLRequest 类从 flash/actionscript 执行 HTTP 请求。该类支持 POST 和 GET。它还支持 HTTPS。
这里是执行 POST 请求的示例。 (顺便说一句,这是当您搜索 "as3 post request")
文档(上面链接)和网络上的其他地方也提供了示例。
编辑:要从 HTTP 服务器检索二进制流数据,您应该使用URLStream。类似下面的内容将通过 POST 请求来完成此操作:
The Socket is not the correct class for this job. Sockets are used for working with raw TCP data connections. For example, you would use Socket to integrate with custom server component that uses a proprietary communications protocol.
Instead, use the URLRequest class to perform HTTP requests from flash/actionscript. This class supports POST as well as GET. It also supports HTTPS.
Here is an example of doing a POST request. (incidentally, that is the first result google gives when you search for "as3 post request")
There are also examples available in the documentation (linked above), and other places around the net.
Edit: To retrieve binary streaming data from an HTTP server, you should use URLStream. Something like the following will accomplish this via a POST request: