Skip to content

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

@GoogleCodeExporter

Description

@GoogleCodeExporter
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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions