Uploaded image for project: 'Wink'
  1. Wink
  2. WINK-317

HttpHeadersImpl.getCookies() only ever returns the first cookie in the Cookie header

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 1.1.1
    • 1.1.2
    • Server
    • None
    • Patch Available

    Description

      org.apache.wink.server.internal.contexts.HttpHeadersImpl.getCookies() iterates over cookie headers but does not iterate over cookies within the header that are split by a semicolon.

      As a result, only 1 cookie is ever returned. This affects using the javax.ws.rs.core.HttpHeaders interface, as well as the javax.ws.rs.CookieParam annotation.

      The fix would be to split the cookie header on the semicolon character, as per RFC 2965. A fix implementation would be:

       
      
          public Map<String, Cookie> getCookies() {
              if (cookies == null) {
                  cookies = new HashMap<String, Cookie>();
                  List<String> cookiesHeaders = headers.get(HttpHeaders.COOKIE);
                  if (cookiesHeaders != null) {
                      for (String cookieHeader : cookiesHeaders) {
                      if (cookieHeader != null){
                          for (String cookieText : split(cookieHeader, ';')){
                              Cookie cookie = Cookie.valueOf(cookieText);
                              if (cookie != null){
                                  cookies.put(cookie.getName(), cookie);
                              }
                          }
                      }
                      }
                  }
              }
              return cookies;
          }
      

      (using org.apache.commons.lang.StringUtils.split() )

      Attachments

        Activity

          People

            bluk Bryant Luk
            chrisfrancuz Chris Francuz
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - 2h
                2h
                Remaining:
                Remaining Estimate - 2h
                2h
                Logged:
                Time Spent - Not Specified
                Not Specified