开发者

Intercepting network calls to force Html header referer to null

I've been using the Flex "HTML" component in my AIR 2.7 project. It's a wrapper for the HtmlLoader class.

The problem is that empty referers in HTML headers are automatically set to "app://[appname].swf". This is not standard as default referer behavior should be to not set any referer at all. The consequence is I'm getting denied access on certain websites using iframes (as location changes from an iframe set an empty referer).

I have no control over those requests has no event is fired when changed the source of an iframe.

I have thought about the possibility of intercepting all network calls and setting the referer to empty when necessary before sending the message. My app is only a container in wich a module is loaded for easier updates so maybe I could set up a proxy on top or something like that.

Is there any way to intercept network messages in Flex??

EDIT :

After some chat with Adobe employees, I opened a bug in Adobe Bug Base about this : https://bugbase.adobe.com/index.cfm?event=bug&id=2945647

More infos extracted from my comments :

I've tried (with Charles proxy) to emulate some cases for a particular site. When sent a blank or valid referer to load some swf file, it passes. However, it denies access on invalid (ex: app://) . That confirms the referrer problem.

there's no formal specification as to what is valid or invalid. I'm referring to what the sites I'm testing on expect. For exemple, cdn.nitrome.com/games/rubbletroubletokyo/rubbletroubletokyo.swf has such a referrer check and will return an "Access Denied." page if the request has been sent with a referrer it considers invalid, such as app://foo.swf or even http://www.google.com. It sends the correct file if no referrer is sent OR with the page that shoul开发者_Python百科d be calling the swf file (http://www.nitrome.com/games/rubbletroubletokyo in this case).

The app is for children and contains a web browser. Only authorized sites are allowed (either by the parents or the publisher) and www.nitrome.com will be one of them at launch. Off course, I have to make sure everything planned at launch will be working! I have succeeded in creating a hack for nitrome.com, but it's REALLY specific. We'll have to create hacks for every website we encounter problems on and that's.. well, time consuming and hard to maintain


As there are no ways of messing with the referrer, we had to implement specific hacks for each website we have problems with (if it's hackable, off course).

Here's what I have done for www.nitrome.com games.

The game page works like this : load an sfw ad inside an iframe, when ad is complete (or user click on skip) it changes the iframe content so that it loads the game swf.

It fails because of the referrer, but I can in code find out (with a timer...) about the content being changed, find the game swf path (regex) and force the frame contentWindow.location to the swf path.

As I said, it's a hack and it's really specific, but it works surprisingly well.


You cannot change the HTTP_Referer value from a Flex App. [source]. To quote:

"Unfortunately, the HTTP Referer cannot be changed from AIR applications "

An alternative is presented, which involves setting up a custom sandbox of sorts; but the thread is left open as to whether this works or not.

The poster seems to have similar frustrating regarding the value in the referrer value. I have to wonder if there is any support for the claim that this is non standard 'referrer behavior.' I'm surprised any web page work fail because a referrer value was specified.


This code worked for me, I checked the headers in fidller. Sometimes if some redirects happen from inside the htmlLoader you get a referer like "http://adobe.com/applolo , I think this are related to some javascript redirecting using window.location but I am not sure, for this case you will need some hooks in JS to prevent this or workaround it.

var urlReq:URLRequest=new URLRequest(urlInput.text);
var headers:URLRequestHeader=new URLRequestHeader("Referer","test");
urlReq.requestHeaders=[];
urlReq.requestHeaders.push(headers);
browser.htmlLoader.load(urlReq);

In the code browser is a HTML object

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜