I appreciate your intentions to help but i realized i would have to edit
the server source and recompile it to add the headers i want to add.

I was successful adding the custom headers to all commands but the "CHECK"
seem to be a problem because adding the headers on the hook killed the long
polling. Which rendered my project useless.

I'm working in an alternative JavaScript framework. I was attempting to
eliminate the need of an iframe for long polling by adding the CORs header
for cross-domain requests.

Here my attempt:

function extraHeaders(){
        //Ape.log(this.http.toSource());
        this.client.write("HTTP/1.1 200 OK\r\n");
        this.client.write("Access-Control-Allow-Origi
n: "+this.http.origin+"\r\n");
        this.client.write("Access-Control-Allow-Metho
ds: POST, GET\r\n");
        this.client.write("Access-Control-Allow-Crede
ntials: true\r\n");
}

Ape.registerHookCmd("connect", extraHeaders);
Ape.registerHookCmd("check", extraHeaders);
Ape.registerHookCmd("send", extraHeaders);
Ape.registerHookCmd("quit", extraHeaders);
Ape.registerHookCmd("join", extraHeaders);
Ape.registerHookCmd("left", extraHeaders);
Ape.registerHookCmd("session", extraHeaders);

Here is the project source if interested:
https://github.com/ptejada/ApePubSub


Sent from my iPhone

On May 1, 2012, at 2:00 AM, Pouya Emami <[email protected]> wrote:

Can you give me some more details on some of the commands that you using.
Maybe tell me what they do? I can try and tell you a bunch of things though
I would be more helpful (hopefully) if I had a better idea of what the
problem is.

Cheers

On Saturday, April 28, 2012 12:32:55 PM UTC-4, Pablo wrote:
>
> I realized i was not clear. I meant a function or event to catch all
> commands . In the client side you could addEvent("onCmd") and that event
> will be triggered on every command. Something like the registerHookBadCmd()
> in the server but for the registered commands.
>
> My intend is to write extra headers to the all the response. My current
> work around is to add a hook to every single command and write the proper
> CORs header.
>
> Sent from my iPhone
>
> On Apr 28, 2012, at 12:09 PM, Pouya Emami <[email protected]> wrote:
>
> I don't mean to be ignorant but have you looked at this page:
> http://www.ape-project.org/wiki/index.php/How_to_build_a_serverside_JS_module
>  ?
>
> It has pretty much all you need to know about the server side data
> manipulation.
>
> On Thursday, April 26, 2012 10:49:33 PM UTC-4, Pablo wrote:
>>
>> On client side you can intercept all outgoing commands with the onCmd()
>> function.
>> Is there any equivalent for the server side?
>>
>  --
> You received this message because you are subscribed to the Google
> Groups "APE Project" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/ape-project?hl=en
> ---
> APE Project (Ajax Push Engine)
> Official website : http://www.ape-project.org/
> Git Hub : http://github.com/APE-Project/
>
>
On Saturday, April 28, 2012 12:32:55 PM UTC-4, Pablo wrote:
>
> I realized i was not clear. I meant a function or event to catch all
> commands . In the client side you could addEvent("onCmd") and that event
> will be triggered on every command. Something like the registerHookBadCmd()
> in the server but for the registered commands.
>
> My intend is to write extra headers to the all the response. My current
> work around is to add a hook to every single command and write the proper
> CORs header.
>
> Sent from my iPhone
>
> On Apr 28, 2012, at 12:09 PM, Pouya Emami <[email protected]> wrote:
>
> I don't mean to be ignorant but have you looked at this page:
> http://www.ape-project.org/wiki/index.php/How_to_build_a_serverside_JS_module
>  ?
>
> It has pretty much all you need to know about the server side data
> manipulation.
>
> On Thursday, April 26, 2012 10:49:33 PM UTC-4, Pablo wrote:
>>
>> On client side you can intercept all outgoing commands with the onCmd()
>> function.
>> Is there any equivalent for the server side?
>>
>  --
> You received this message because you are subscribed to the Google
> Groups "APE Project" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/ape-project?hl=en
> ---
> APE Project (Ajax Push Engine)
> Official website : http://www.ape-project.org/
> Git Hub : http://github.com/APE-Project/
>
>  --
You received this message because you are subscribed to the Google
Groups "APE Project" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/ape-project?hl=en
---
APE Project (Ajax Push Engine)
Official website : http://www.ape-project.org/
Git Hub : http://github.com/APE-Project/

-- 
You received this message because you are subscribed to the Google
Groups "APE Project" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/ape-project?hl=en
---
APE Project (Ajax Push Engine)
Official website : http://www.ape-project.org/
Git Hub : http://github.com/APE-Project/

Reply via email to