使用 Google Chrome 时如何通过 Flex 发送自定义 HTTP 标头

发布于 2024-07-15 19:48:23 字数 574 浏览 5 评论 0原文

我正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

苍风燃霜 2024-07-22 19:48:23

浏览器限制 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

傲影 2024-07-22 19:48:23

但我已经在使用数据字段
在本例中发送 XML 流

定义您的 xml 模型以包含这些标头。 从你的问题来看,你觉得你的数据属性受到限制。

<xmlObjects>
    <headers>
        <header name="header1" value="foo" />
        <header name="header1" value="foo" />
    </headers>
    <data>
        <ip>102.201.102.1</ip>
        <name>Andrew Rea</name>
    </data>
</xmlObjects>

因此,如果我需要发送任何数据,我依赖于传输数据的模型的设计。

安德鲁

but I am already using the data field
in this case to send an XML stream

Define your xml model to contain these headers. From your question it sounds like you feel you are restricted with the data proprty.

<xmlObjects>
    <headers>
        <header name="header1" value="foo" />
        <header name="header1" value="foo" />
    </headers>
    <data>
        <ip>102.201.102.1</ip>
        <name>Andrew Rea</name>
    </data>
</xmlObjects>

So if I need to send any data I rely on the design of the model which will transport the data.

Andrew

热血少△年 2024-07-22 19:48:23

如何在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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文