使用 Google Chrome 时如何通过 Flex 发送自定义 HTTP 标头
我正在使用 UrlRequest 将数据发送到服务器。 我按以下方式通过自定义 HTTP 标头发送各种参数:
urlRequest.requestHeaders.push(new URLRequestHeader("someheader", "somevalue"));
当请求到达我的 ASP.NET 端点(实现 IHttpHandler 的类)时,如果运行我的 Flex 应用程序的 Web 浏览器是 Google,则 HttpRequest Headers 属性不包含任何值铬合金。 这适用于 IE6、IE7 和 Firefox。 当我使用 Fiddler 查看流量时,如果浏览器是 Chrome,则自定义标头不存在。 我在服务器上的 crossdomain.xml 是完全开放的,以允许所有标头:
<allow-http-request-headers-from domain="*" headers="*"/>
我知道通常通过将 UrlRequest 的数据属性设置为 UrlVariables 字典来发送参数,但在本例中我已经使用数据字段来发送 XML 流。
I am using a UrlRequest to send data to a server. I am sending various parameters via custom HTTP headers in the following way:
urlRequest.requestHeaders.push(new URLRequestHeader("someheader", "somevalue"));
When the request hits my ASP.NET endpoint (a class implementing IHttpHandler), the HttpRequest Headers property doesn't contain any values if the web browser running my Flex App is Google Chrome. This works fine for IE6, IE7, and Firefox. When I look at the traffic with Fiddler, the custom headers are not there if the browser is Chrome. My crossdomain.xml on the server is wide open to allow all headers:
<allow-http-request-headers-from domain="*" headers="*"/>
I know that typically parameters are sent over by setting the UrlRequest's data property to a UrlVariables dictionary, but I am already using the data field in this case to send an XML stream.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
浏览器限制 Flash 应用程序在发出 HTTP 请求时可以发送的标头。 不同的浏览器有不同的限制,但它们都有限制。
我最终在我的服务器上创建了一个代理,这样我就可以发送与各种第三方服务器通信所需的所有标头。
-布莱恩
Browsers limit the headers a flash app can send when making an HTTP request. Different browsers have different limits but they all have limits.
I eventually created a proxy on my server so I could send all the headers I needed for communication with various third party servers.
-brian
定义您的 xml 模型以包含这些标头。 从你的问题来看,你觉得你的数据属性受到限制。
因此,如果我需要发送任何数据,我依赖于传输数据的模型的设计。
安德鲁
Define your xml model to contain these headers. From your question it sounds like you feel you are restricted with the data proprty.
So if I need to send any data I rely on the design of the model which will transport the data.
Andrew
如何在flex中发送自定义http标头的方法
http://yasob.blogspot.com/2009/05/accessing-http-request-parameter-in.html
Ways how to send custom http header in flex
http:// yasob.blogspot.com/2009/05/accessing-http-request-parameter-in.html