的URLRequest /的URLLoader自动转换POST请求为GET [英] URLRequest/URLLoader auto-converting POST request to GET

查看:362
本文介绍了的URLRequest /的URLLoader自动转换POST请求为GET的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我执行以下code:

When I execute the following code:

var urlRequest:URLRequest = new URLRequest("http://somehost/with/some/path?andsomequerystring=true");
urlRequest.method = 'POST';
var urlLoader:URLLoader = new URLLoader(urlRequest);
urlLoader.addEventListener(Event.COMPLETE,  function(event:Event):void{
    trace('sweet');
});

原来我明确POST请求由于查询字符串的presence得到的。如果我删除的查询字符串(和序列化作为POST身体的一部分),它成功地做出相应的POST请求。有没有什么办法prevent它这样做?我的服务器要求POST请求与查询字符串进行。

It turns my explicit POST request to GET due to the presence of the querystring. If I remove the querystring (and serialize as part of the POST body), it successfully makes the corresponding POST request. Is there any way to prevent it from doing that? My server requires that a POST request be made with a querystring.

推荐答案

啊想我找到了答案,看来你需要指定一个机构为好,否则,仍然会发送从他们的文档GET请求:

Ah think I found the answer, seems you have to specify a body as well or else it will still send as a GET request from their docs:

请注意:如果在Flash Player和引用的形式运行没有正文,   Flash Player会自动使用GET操作,即使该方法是   设置为URLRequestMethod.POST。出于这个原因,建议   始终包括虚拟正文以确保正确的方法是   用了。

Note: If running in Flash Player and the referenced form has no body, Flash Player automatically uses a GET operation, even if the method is set to URLRequestMethod.POST. For this reason, it is recommended to always include a "dummy" body to ensure that the correct method is used.

<一个href="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/URLRequest.html#url">http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/URLRequest.html#url

这篇关于的URLRequest /的URLLoader自动转换POST请求为GET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆