Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom headers possible with URLRequest/URLStream using method GET?

Quite simple really:

var req:URLRequest=new URLRequest();
req.url="http://somesite.com";
var header:URLRequestHeader=new URLRequestHeader("my-bespoke-header","1");
req.requestHeaders.push(header);
req.method=URLRequestMethod.GET;
stream.load(req);

Yet, if I inspect the traffic with WireShark, the my-bespoke-header is not being sent. If I change to URLRequestMethod.POST and append some data to req.data, then the header is sent, but the receiving application requires a GET not a POST.

The documentation mentions a blacklist of headers that will not get sent. my-bespoke-header is not one of these. It's possibly worth mentioning that the originating request is from a different port on the same domain. Nothing is reported in the policyfile log, so it seems unlikely, but is this something that can be remedied by force loading a crossdomain.xml with a allow-http-request-headers-from despite the fact that this is not a crossdomain issue? Or is it simply an undocumented feature of the Flash Player that it can only send custom headers with a POST request?

like image 866
spender Avatar asked Dec 17 '22 10:12

spender


2 Answers

From what I can gather, it seems like your assumption about the lack of custom headers support for HTTP GET is indeed an undocumented feature (or a bug?) in the standard libraries.

In any case, you might want to see if as3httpclient would fit your purposes and let you work around this issue. Here's a relevant snippet from a post in the blog of the developer of this library:

"I was not able to set the header of a HTTP/GET request. Macromedia Flash Player allows you set the header only for POST requests. I discussed this issues with Ted Patrick and he told me how I can us Socket to achieve the desired and he was very kind to give a me code-snippet, which got me started."

like image 180
hasseg Avatar answered Jan 21 '23 14:01

hasseg


If this limitation was undocumented at one time, that's no longer the case. See:

http://livedocs.adobe.com/flex/3/langref/flash/net/URLRequest.html#requestHeaders

"[...] Due to browser limitations, custom HTTP request headers are only supported for POST requests, not for GET requests. [...]"

like image 26
Chris W. Rea Avatar answered Jan 21 '23 12:01

Chris W. Rea