The other day a developer named Carlo emailed me noted that currently URLRequestHeader is not exposed via ScriptCoreLib. In response to that I exposed those classes and created an example solution to demonstrate it. You would need to redownload jsc to get it ofcourse.
Before going into that I would like to show how one could add a native type that is not yet defined by other assemblies like ScriptCoreLib. In your assembly you would need to define a new type like this:
6 namespace ScriptCoreLib.ActionScript.flash.net
7 {
8 // http://livedocs.adobe.com/flex/3/langref/flash/net/URLRequestHeader.html
9 [Script(IsNative = true)]
10 public class URLRequestHeader
11 {
The compiler will later then assume that this type is provided by the platform itself or imported by some other means and use it as a native type.
The actionscript livedocs had a nice example which I translated to C#.
44 var loader = new URLLoader();
45
46 var header = new URLRequestHeader(“XMyHeader”, “got milk?”);
47
48 t.appendText(“\n” + this.loaderInfo.url);
49 t.appendText(“\nUsing relative path…”);
50
51 var request = new URLRequest(“../WebForm1.aspx”);
52 var data = new DynamicContainer { Subject = new URLVariables(“name=John+Doe”) };
53 data["age"] = 23;
54
55 request.data = data.Subject;
56 request.method = URLRequestMethod.POST;
57 request.requestHeaders.push(header);
58
59 loader.complete +=
60 args =>
61 {
62 t.appendText(“\n” + loader.data);
63 };
64
65 loader.load(request);
In this demo I am sending three elements of data to the server:
- header XMyHeader
- post parameter name
- post parameter age
As we need a server to echo something back for us to see it works I added a new ASP.NET Web Application to the solution. The flash file generated by the jsc compiler will be copied to a folder Generated. The generated files are not included in the svn. This is why the solution will show exclamation marks on the first build.

The WebForm1 implements the echo service like this:
10 public partial class WebForm1 : System.Web.UI.Page
11 {
12 protected void Page_Load(object sender, EventArgs e)
13 {
14 var data = new
15 {
16 XMyHeader = this.Request.Headers["XMyHeader"],
17 name = this.Request.Params["name"],
18 age = this.Request.Params["age"],
19
20 };
21
22 this.Response.Write(“hi! “ + data.ToString());
23 this.Response.End();
24 this.Response.Close();
25 }
26 }
Running it in the browser will give us the following view including the current URL and the text returned by the server.

The source code for this example is available here:
http://jsc.svn.sourceforge.net/viewvc/jsc/examples/actionscript/URLRequestHeaderExample/
As this is a dirty fast example – If anything needs clarification do let me know.