Package org.w3c.www.http

Examples of org.w3c.www.http.HttpSetCookie


     * @param cookie - the Cookie to return to the client
     */
    public void addCookie(Cookie cookie) {
  HttpSetCookieList clist = reply.getSetCookie();
  if (clist == null) {
      HttpSetCookie cookies [] = new HttpSetCookie[1];
      cookies[0] = convertCookie(cookie);
      clist = new HttpSetCookieList(cookies);
  } else {
      clist.addSetCookie(convertCookie(cookie));
  }
View Full Code Here


  }
  reply.setSetCookie(clist);
    }

    private HttpSetCookie convertCookie(Cookie cookie) {
  HttpSetCookie scookie = new HttpSetCookie(true,
              cookie.getName(),
              cookie.getValue());
  scookie.setComment(cookie.getComment());
  scookie.setDomain(cookie.getDomain());
  scookie.setMaxAge(cookie.getMaxAge());
  scookie.setPath(cookie.getPath());
  scookie.setSecurity(cookie.getSecure());
  scookie.setVersion(cookie.getVersion());
  return scookie;
    }
View Full Code Here

      HttpRangeList rl = (HttpRangeList) hvalue;
      rl.addRange(HttpFactory.parseRange(value));
  } else if (hvalue instanceof HttpSetCookieList) {
      HttpSetCookieList scl = (HttpSetCookieList) hvalue;
      HttpSetCookieList nscl = HttpFactory.parseSetCookieList(value);
      HttpSetCookie scookies[] = nscl.getSetCookies();
      for (int i = 0 ; i < scookies.length ; i++) {
    scl.addSetCookie(scookies[i]);
      }
  } else if (hvalue instanceof HttpTokenList) {
      ((HttpTokenList) hvalue).addToken(value, true);
View Full Code Here

      i++;
  }
  if (nbcookies < cookies.length) {
      cookies[nbcookies++] = cookie;
  } else {
      HttpSetCookie ncookies [] = new HttpSetCookie[cookies.length +1];
      System.arraycopy(cookies,0,ncookies,0,cookies.length);
      ncookies[nbcookies++] = cookie;
      cookies = ncookies;
  }
    }
View Full Code Here

    cookie.getValue()+ //6
    "\n");
    }

    protected HttpSetCookie string2Cookie(String cookie[]) {
  HttpSetCookie cook = new HttpSetCookie();
  cook.setDomain(cookie[0]);
  cook.setSecurity(Boolean.getBoolean(cookie[1].toLowerCase()));
  cook.setPath(cookie[2]);
  long expire = Long.parseLong(cookie[3]);
  long now = (new Date()).getTime();
  cook.setMaxAge((int) ((expire - now) / 1000));
  cook.setVersion(Integer.parseInt(cookie[4]));
  cook.setName(cookie[5]);
  cook.setValue(cookie[6]);
  return cook;
    }
View Full Code Here

      if (ch == -1) return;
        break;
    case '\n':
        if (i > 0) {
      cookie[i++] = buffer.toString();
      HttpSetCookie setcookie = string2Cookie(cookie);
      if (setcookie.getMaxAge() > 0)
          insertCookie(setcookie);
      buffer = new StringBuffer(30);
      cookie = new String[8];
      i = 0;
        }
View Full Code Here

TOP

Related Classes of org.w3c.www.http.HttpSetCookie

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.