jcricket / gwt-syncproxy

Provides Synchronous and Asynchronous access to GWT-RPC servlets from Java and Android
http://www.blueesoteric.com/open-source/gwt-syncproxy
Apache License 2.0
23 stars 14 forks source link

CookieManager's cookies are not actually sent in requests #21

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Try to add cookies to a RemoteService. cookies are not passed in the request:

        CookieManager empSession = new CookieManager();
        CookieStore cookieStore = empSession.getCookieStore();      
        cookieStore.add(new URI("http://example.com/gwtApp"), new HttpCookie("sessionToken", "123456789"));
        empSession = new CookieManager(cookieStore, CookiePolicy.ACCEPT_ALL);

        ExampleRemoteService exampleService = (ExampleRemoteService) SyncProxy.newProxyInstance(ExampleRemoteService.class, "http://example.com/gwtApp", "exampleSvc", empSession); 

making a request like exampleService.exampleMethod() does not include the 
cookie in the request

What is the expected output? What do you see instead?
In the header of the request, I'd expect to see:
"Cookie: sessionToken=123456789"

What version of the product are you using? On what operating system?
0.3.1

Please provide any additional information below.

Here's code to fix this. Add it to RemoteServiceSyncProxy.java after line 147 
(connection.setRequestProperty...)

      CookieStore store = cookieManager.getCookieStore();
      String cookiesStr = "";
      for(HttpCookie cookie : store.getCookies()) {       
          if(!"".equals(cookiesStr)) cookiesStr += "; "; 
          cookiesStr += cookie.getName() +"="+ cookie.getValue();
      }
      connection.setRequestProperty("Cookie", cookiesStr);

Original issue reported on code.google.com by david.bu...@sagebase.org on 22 Dec 2011 at 10:08

GoogleCodeExporter commented 9 years ago
I initially used the provided patch but found that in a specific circumstance, 
the cookies were duplicated. Digging a little deeper, the issue appears to 
actually be related to the creation of the HttpCookie. In order to be 
automatically sent with the request, the #path and must be set on the 
HttpCookie. I have modified the RemoteServiceSyncProxy to automatically add the 
appropriate path (if missing), so this should be resolved in the 0.5 release, 
available later this weekend. Please keep an eye out for the new wiki 
documentation.

Original comment by p.pr...@blueesoteric.com on 10 Jan 2015 at 8:57

GoogleCodeExporter commented 9 years ago
Issue 30 has been merged into this issue.

Original comment by p.pr...@blueesoteric.com on 10 Jan 2015 at 9:00

GoogleCodeExporter commented 9 years ago
SyncProxy library version 0.5 is now available

Original comment by p.pr...@blueesoteric.com on 11 Jan 2015 at 4:31