Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Is it possible to use the session in an async request?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  7 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
James Roper  
View profile  
 More options Apr 12 2012, 9:12 am
From: James Roper <jrop...@gmail.com>
Date: Thu, 12 Apr 2012 06:12:08 -0700 (PDT)
Local: Thurs, Apr 12 2012 9:12 am
Subject: [2.0] Is it possible to use the session in an async request?

Before I raise a bug report, I wanted to sanity check that I'm doing things
right.

I have code that looks (very) roughly like this:

public static Resut login(final String user, String password) {
  final Http.Context ctx = ctx();
  return async(WS.url("https://myssoprovider.com/login?user=" + user +
"&password=" + password).map(
    new Function<WS.Response, Result>() {
      public Result apply(WS.Response response) {
        if (response.status == 200) {
          ctx.session().put("user", user);
          return ok();
        } else {
          return notFound();
        }
      }
    });
  }

}

My first attempt was to use ctx() from within the map function, this of
course just threw an exception because the context is not set in the thread
local for the thread that handles the response.  But it seems not even
getting the context before the async part and then using that works, I can
put stuff in the session, but it seems no cookies get returned to the
client.  Is there another way to set session data in asynchronous requests?

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Discussion subject changed to "[2.0] Is it possible to use the session in an async request?" by Kevin Bosman
Kevin Bosman  
View profile  
 More options Apr 12 2012, 9:35 am
From: Kevin Bosman <ke...@gosh.co.za>
Date: Thu, 12 Apr 2012 15:35:12 +0200
Local: Thurs, Apr 12 2012 9:35 am
Subject: Re: [play-framework] [2.0] Is it possible to use the session in an async request?

> Before I raise a bug report, I wanted to sanity check that I'm doing things
> right.

Hi James,

You're doing it right, but...

The issue is the same one causing problems like those mentioned here:
https://groups.google.com/d/msg/play-framework/-/vLHFKFu9du4J

Please Guillaume's response in that thread.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
James Roper  
View profile  
 More options Apr 12 2012, 11:27 am
From: James Roper <jrop...@gmail.com>
Date: Thu, 12 Apr 2012 08:27:33 -0700 (PDT)
Local: Thurs, Apr 12 2012 11:27 am
Subject: Re: [play-framework] [2.0] Is it possible to use the session in an async request?

If this is the pull request that Guillaume is referencing, then no, it
looks to me like it won't fix it:

https://github.com/playframework/Play20/pull/230

That pull request is only copying headers across.  I could be wrong, but it
looks to me like at that point, the session data is still just in a plain
map, and not encoded into a set cookie header in the response.  Anyway,
this has confirmed that it's a bug, so I'll raise an issue.  Hopefully it
can be fixed in a 2.0.x release.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
James Roper  
View profile  
 More options Apr 12 2012, 11:32 am
From: James Roper <jrop...@gmail.com>
Date: Thu, 12 Apr 2012 08:32:30 -0700 (PDT)
Local: Thurs, Apr 12 2012 11:32 am
Subject: Re: [play-framework] [2.0] Is it possible to use the session in an async request?

Created here:

https://play.lighthouseapp.com/projects/82401-play-20/tickets/350-ses...


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Kevin Bosman  
View profile  
 More options Apr 12 2012, 2:56 pm
From: Kevin Bosman <ke...@gosh.co.za>
Date: Thu, 12 Apr 2012 20:56:14 +0200
Local: Thurs, Apr 12 2012 2:56 pm
Subject: Re: [play-framework] [2.0] Is it possible to use the session in an async request?

> it looks to me like at that point, the session data is still just in a plain
> map, and not encoded into a set cookie header in the response.

James, you're absolutely correct.
I've responded to your lighthouse ticket #350 with a solution to the problem.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ali Russell  
View profile  
 More options Apr 24 2012, 7:31 am
From: Ali Russell <a...@tray.io>
Date: Tue, 24 Apr 2012 04:31:25 -0700 (PDT)
Local: Tues, Apr 24 2012 7:31 am
Subject: Re: [play-framework] [2.0] Is it possible to use the session in an async request?

Thanks for this Kevin, your patch solved the issue for me, although there
was a warning about unsafe operations in Result.java?

Is there any idea when this will be looked at and merged into master..? im
not sure what the timeline is for the 2.1 release or if there has already
been a cutoff?

Thanks

Ali


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Kevin Bosman  
View profile  
 More options Apr 24 2012, 10:33 am
From: Kevin Bosman <ke...@gosh.co.za>
Date: Tue, 24 Apr 2012 16:33:21 +0200
Local: Tues, Apr 24 2012 10:33 am
Subject: Re: [play-framework] [2.0] Is it possible to use the session in an async request?
Hi Ali,

> ...although there
> was a warning about unsafe operations in Result.java?

The warnings are actually from a different part of Results.java, and
were present even before my change.

> Is there any idea when this will be looked at and merged into master..? im
> not sure what the timeline is for the 2.1 release or if there has already
> been a cutoff?

I'm sorry, but I have no idea! I don't think there has been a cutoff
yet, and I would speculate that a 2.0.1 bugfix release is imminent.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »