且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

与具有相同名称的多个参数发送HTTP请求

更新时间:2023-02-23 21:31:35

虽然POST可以为同一个键有多个值,我会谨慎使用它,因为有些服务器甚至不能正确处理,这是也许这是为什么不支持?如果您将重复的参数列表,整个事情可能会开始呛,如果一个参数来仅一次,suddendly你风有一个字符串或东西...但我想你知道自己在做什么......

Although POST may be having multiple values for the same key, I'd be cautious using it, since some servers can't even properly handle that, which is probably why this isn't supported ... if you convert "duplicate" parameters to a list, the whole thing might start to choke, if a parameter comes in only once, and suddendly you wind up having a string or something ... but i guess you know what you're doing ...

我很抱歉这样说,但你想要做的,是不可能在纯粹的AS2 ...唯一的2类适用于HTTP是 Load忱 XML ...技术上也的loadVariables ,但它只是复制传递的对象属性进请求,这没有按'T改变你的问题,因为属性是唯一...

I am sorry to say so, but what you want to do, is not possible in pure AS2 ... the only 2 classes available for HTTP are LoadVars and XML ... technically there's also loadVariables, but it will simply copy properties from the passed object into the request, which doesn't change your problem, since properties are unique ...

如果你想坚持到AS2,你需要一个中间层:

if you want to stick to AS2, you need an intermediary tier:

  1. 在一台服务器转移呼叫。如果你有机会到服务器,然后创建了AS2客户提供新的端点,这将取消$ C C的请求,$,并将其传递给正常的终点。
  2. 使用的JavaScript。与 flash.external :: ExternalInterface的,你可以调用JavaScript code。您需要定义一个回调,当操作完成的,还有,你可以调用(还有其他的方式,但是这应该足够了)JavaScript函数。建立内部闪存的请求字符串,用泵为JavaScript和让的JavaScript它在一个POST请求发送到服务器,并获得响应回Flash通过回调。
  1. a server to forward your calls. if you have access to the server, then you create a new endpoint for AS2 clients, which will decode the requests and pass them to the normal endpoint.
  2. use javascript. with flash.external::ExternalInterface you can call JavaScript code. You need to define a callback for when the operation is done, as well as a JavaScript function that you can call (there are other ways but this should suffice). Build the request string inside flash, pump it to JavaScript and let JavaScript send it to the server in a POST request and get the response back to flash through the callback.

由你来决定哪一个是更多的工作...

up to you to decide which one is more work ...

侧面说明:的在AS3中,你会使用 flash.net::URLLoader DATAFORMAT 设置为 flash.net::URLLoaderDataFormat.TEXT ,然后重新连接code参数为一个字符串,并把他们。

side note: in AS3, you'd use flash.net::URLLoader with dataFormat set to flash.net::URLLoaderDataFormat.TEXT, and then again encode parameters to a string, and send them.