HTTPService persistant cookies in AIR

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

HTTPService persistant cookies in AIR

David Coleman

Hi List, I have a question about HTTPService, cookies and PHP sessions.

I have years of experience with flex and PHP.  I'm using CakePHP which uses a combination of cookies and session vars to maintain a login for the user.

I have an AIR app, and I really don't want to use the URLLoader component (which does properly allow me to set cookies), because it does not give me an AsyncToken.  I need the AsyncToken to be able to manage my service stack due to requirements of my application.

I do the following and it has NO effect whatsoever:

var service:HTTPService = new HTTPService();
service.headers = {Cookies:"foo=bar"};
service.method = "POST";
service.url = "localhost/foo/foo/foo";  // some url of some json service in my cake app
service.send();


(I don't need to send a payload because it uses url routing).

I'm using the flex sdk 4.6.

here are my problems:
The cookies simply don't get to the server.  I've put a "var_dump($_COOKIES); die();" in the first line of my index.php and nothing...The request reaches the server as a GET, which I've found is a result of having an empty payload.
I know that this list is more for questions on Apache Flex... but I'm curious, is this a behavior that is fixed in Apache Flex?  Are there known workarounds in Adobe Flex 4.6?  Is there something I'm doing wrong, or is it as everything I google suggests, that it is a total failure of the HTTPService object to properly handle headers?
Sincerely,David K. Coleman
     
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: HTTPService persistant cookies in AIR

Jonathan Campos
Long story short. It is an issue with HTTPService and how it deals with
headers. It swallows them up.

Sorry, but you're going to have to code around this issue.

J

On Wed, Apr 25, 2012 at 8:50 AM, David Coleman <
[hidden email]> wrote:

>
> Hi List, I have a question about HTTPService, cookies and PHP sessions.
>
> I have years of experience with flex and PHP.  I'm using CakePHP which
> uses a combination of cookies and session vars to maintain a login for the
> user.
>
> I have an AIR app, and I really don't want to use the URLLoader component
> (which does properly allow me to set cookies), because it does not give me
> an AsyncToken.  I need the AsyncToken to be able to manage my service stack
> due to requirements of my application.
>
> I do the following and it has NO effect whatsoever:
>
> var service:HTTPService = new HTTPService();
> service.headers = {Cookies:"foo=bar"};
> service.method = "POST";
> service.url = "localhost/foo/foo/foo";  // some url of some json service
> in my cake app
> service.send();
>
>
> (I don't need to send a payload because it uses url routing).
>
> I'm using the flex sdk 4.6.
>
> here are my problems:
> The cookies simply don't get to the server.  I've put a
> "var_dump($_COOKIES); die();" in the first line of my index.php and
> nothing...The request reaches the server as a GET, which I've found is a
> result of having an empty payload.
> I know that this list is more for questions on Apache Flex... but I'm
> curious, is this a behavior that is fixed in Apache Flex?  Are there known
> workarounds in Adobe Flex 4.6?  Is there something I'm doing wrong, or is
> it as everything I google suggests, that it is a total failure of the
> HTTPService object to properly handle headers?
> Sincerely,David K. Coleman
>




--
Jonathan Campos
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: HTTPService persistant cookies in AIR

David Coleman

Thanks, J.

I am going to search through the code for HTMLService and see if I can monkey patch it and repackage it in my project to properly handle it.  I really want the simplicity of HTMLService vs. the token-less mess of the URLLoader/URLRequest combo.

Maybe this is fodder for the flex-dev list if this is not yet fixed in Apache Flex either.

-Dave
     
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: HTTPService persistant cookies in AIR

Jonathan Campos
Maybe :)

I know it is a pain, I actually am having to deal with that these days too.
Well, I am advising a team on how to deal with that. And I recommended them
extending HTTPService and adding in the support they need.

On Wed, Apr 25, 2012 at 9:23 AM, David Coleman <
[hidden email]> wrote:

>
> Thanks, J.
>
> I am going to search through the code for HTMLService and see if I can
> monkey patch it and repackage it in my project to properly handle it.  I
> really want the simplicity of HTMLService vs. the token-less mess of the
> URLLoader/URLRequest combo.
>
> Maybe this is fodder for the flex-dev list if this is not yet fixed in
> Apache Flex either.
>
> -Dave
>




--
Jonathan Campos
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: HTTPService persistant cookies in AIR

David Coleman

If i fix it in a nice way, I'll share it w/the flex-dev group...  This is just a disgrace that the flagship "service" class does not support cookies or sessions properly.

> From: [hidden email]
> Date: Wed, 25 Apr 2012 09:28:33 -0500
> Subject: Re: HTTPService persistant cookies in AIR
> To: [hidden email]
>
> Maybe :)
>
> I know it is a pain, I actually am having to deal with that these days too.
> Well, I am advising a team on how to deal with that. And I recommended them
> extending HTTPService and adding in the support they need.
>
> On Wed, Apr 25, 2012 at 9:23 AM, David Coleman <
> [hidden email]> wrote:
>
> >
> > Thanks, J.
> >
> > I am going to search through the code for HTMLService and see if I can
> > monkey patch it and repackage it in my project to properly handle it.  I
> > really want the simplicity of HTMLService vs. the token-less mess of the
> > URLLoader/URLRequest combo.
> >
> > Maybe this is fodder for the flex-dev list if this is not yet fixed in
> > Apache Flex either.
> >
> > -Dave
> >
>
>
>
>
> --
> Jonathan Campos
     
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: HTTPService persistant cookies in AIR

Brett Adam
In reply to this post by David Coleman
Take a look at my old blog posting on the evil things HTTPService does and how you can workaround most of them. I do manage to send headers, btw.

http://verveguy.blogspot.com/2008/07/truth-about-flex-httpservice.html

Note that I have built a deeper hack-around that involves some nasty monkey-patching of the layers underneath HTTPService  - although no outright code changes to any SDK classes. I'm happy to share it if you're willing to hold your nose.

Regards

Brett


On Apr 25, 2012, at 9:50 AM, David Coleman wrote:

>
> Hi List, I have a question about HTTPService, cookies and PHP sessions.
>
> I have years of experience with flex and PHP.  I'm using CakePHP which uses a combination of cookies and session vars to maintain a login for the user.
>
> I have an AIR app, and I really don't want to use the URLLoader component (which does properly allow me to set cookies), because it does not give me an AsyncToken.  I need the AsyncToken to be able to manage my service stack due to requirements of my application.
>
> I do the following and it has NO effect whatsoever:
>
> var service:HTTPService = new HTTPService();
> service.headers = {Cookies:"foo=bar"};
> service.method = "POST";
> service.url = "localhost/foo/foo/foo";  // some url of some json service in my cake app
> service.send();
>
>
> (I don't need to send a payload because it uses url routing).
>
> I'm using the flex sdk 4.6.
>
> here are my problems:
> The cookies simply don't get to the server.  I've put a "var_dump($_COOKIES); die();" in the first line of my index.php and nothing...The request reaches the server as a GET, which I've found is a result of having an empty payload.
> I know that this list is more for questions on Apache Flex... but I'm curious, is this a behavior that is fixed in Apache Flex?  Are there known workarounds in Adobe Flex 4.6?  Is there something I'm doing wrong, or is it as everything I google suggests, that it is a total failure of the HTTPService object to properly handle headers?
> Sincerely,David K. Coleman
>    


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: HTTPService persistant cookies in AIR

David Coleman

Hey there Brett!!!  I already found your blog, and it was rather helpful...

How stinky is your hack-around... I'm thinking of making a serious sdk level patch and posting it up to the guys on flex-dev because I can't believe how this has not been fixed already.  It limits our ability to develop services so greatly, forcing us to use sub-optimal classes to monkey patch bugs that should never even have left a local environment much less have been released as a "stable" sdk.

I'd love to see your patch maybe I can use parts of it (and don't worry about stinky code, i've seen - and written - my own fair share).

-Dave
     
Loading...