/*
@see
com.ibm.ws.http.channel.internal.values.CookieData#set(com.ibm.websphere
.http.HttpCookie, byte[])
194117
@Override
    @SuppressWarnings("unused")
    public boolean set(HttpCookie cookie, byte[] data) {
        cookie.setDiscard(true);
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "Cookie Discard attribute set");
        }
        return true;
    }
443925
public void set(byte[] newData, int offset, int length) {
    setSize(0);
    setSize(length);
    System.arraycopy(newData, offset, bytes, 0, size);
  }
1368046
public static void setRawCookie(String name, String value, HttpServletRequest req,
			HttpServletResponse res, boolean httpOnly, int maxAge) {
		if (StringUtils.isBlank(name) || value == null || req == null || res == null) {
			return;
		}
		Cookie cookie = new Cookie(name, value);
		cookie.setHttpOnly(httpOnly);
		cookie.setMaxAge(maxAge < 0 ? Config.SESSION_TIMEOUT_SEC : maxAge);
		cookie.setPath("/");
		cookie.setSecure(req.isSecure());
		res.addCookie(cookie);
	}
537190
public void setResponse(byte[] contentType, byte[] value) {
        int valueSize = (value == null) ? 0 : value.length;
        byte[] len = stringToBytes(String.valueOf(valueSize));
        int size = RES_200.length;
        if (contentType != null) {
            size += CONTENT_TYPE.length;
            size += contentType.length;
            size += TextCommandConstants.RETURN.length;
        }
        size += CONTENT_LENGTH.length;
        size += len.length;
        size += TextCommandConstants.RETURN.length;
        size += TextCommandConstants.RETURN.length;
        size += valueSize;
        this.response = ByteBuffer.allocate(size);
        response.put(RES_200);
        if (contentType != null) {
            response.put(CONTENT_TYPE);
            response.put(contentType);
            response.put(TextCommandConstants.RETURN);
        }
        response.put(CONTENT_LENGTH);
        response.put(len);
        response.put(TextCommandConstants.RETURN);
        response.put(TextCommandConstants.RETURN);
        if (value != null) {
            response.put(value);
        }
        response.flip();
    }
589816
public void setCookie(String name, String value, String path, Date expirationDate, boolean secure, boolean httpOnly) {
        if (remote == null)
            throw new IllegalStateException("Cannot setCookie since remote == null");
        if (path == null || path.length() == 0)
            path = remote.getPath();
        Cookie.Builder builder = new Cookie.Builder();
        builder.name(name).value(value).domain(remote.getHost()).path(path);
        if (expirationDate != null)
            builder.expiresAt(expirationDate.getTime());
        List<Cookie> cookies = Collections.singletonList(builder.build());
        this.clientFactory.addCookies(cookies);
    }
1259108
public void addSetCookie(String name,
                             String value)
    {
        _header.addSetCookie(new Cookie(name,value));
    }
1079394
@Override
    public byte[] set(byte[] key, byte[] value, int expireTime) {
        if (key == null) {
            return null;
        }
        Jedis jedis = getJedis();
        try {
            jedis.set(key, value);
            // -1 and 0 is not a valid expire time in Jedis
            if (expireTime > 0) {
                jedis.expire(key, expireTime);
            }
         } finally {
            jedis.close();
        }
        return value;
    }
829467
@Override
    public void set(Event<?> value) throws InvocationException {
        try {
            if (!field.isAccessible()) {
                field.setAccessible(true);
            }
            field.set(target, value);
        } catch (Exception e) {
            throw new InvocationException(e);
        }
    }
1257861
public static void setCookieValue(HttpServletResponse response, String cookieName,
            String cookieValue, int expireInHour) {
        Cookie cookie = new Cookie(cookieName, cookieValue);
        if (expireInHour > 0) {
            cookie.setMaxAge(60 * 60 * 24 * expireInHour);
        } else {
            cookie.setMaxAge(60 * 60 * 24);
        }
        response.addCookie(cookie);
    }
608634
public void setData(byte[] bytes, byte[] sourceMap) {
		this.sourceMap = sourceMap;
		sourceMapSize = sourceMap != null ? sourceMap.length : 0;
		setBytes(bytes);
	}
1222645
public void setCookies(HttpURLConnection http) {

		// Only save cookies if FLAGS_ENABLE_COOKIES has been set.
		if((flags & XMLRPCClient.FLAGS_ENABLE_COOKIES) == 0)
			return;

		String concat = "";
		for(Map.Entry<String,String> cookie : cookies.entrySet()) {
			concat += cookie.getKey() + "=" + cookie.getValue() + "; ";
		}
		http.setRequestProperty(COOKIE, concat);

	}
347092
public void setCookie(final String name, final String value) {
		if (name != null) {
			Cookie cookie = new Cookie(name, value);
			cookies.put(name, cookie);
		}
	}
1203919
public void sendCookie(String name, String value) {
        RequestContext.getHttpResponse().addCookie(Cookie.toServletCookie(new Cookie(name, value)));
    }
1069910
public static void setCookieValue(HttpServletResponse response, String key, String value)
	{
		setCookieValue(response, key, value, "/", -1);
	}
1222759
public void setData(byte[] data, int offset, int length) {
        if (immutable) {
            throw new IllegalStateException(ERR_MSG_IMMUTABLE);
        }
        this.data = new byte[length];
        System.arraycopy(data, offset, this.data, 0, length);
    }
487147
@Override
    @SuppressWarnings("unused")
    public boolean set(HttpCookie cookie, byte[] attribValue) {

        // The mere presence of the SECURE attribute means that
        // this attrib is set
        cookie.setSecure(true);
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "Cookie secure set to " + cookie.isSecure());
        }
        return true;
    }
310473
public HttpServerExchange setResponseCookie(final Cookie cookie) {
        if(getConnection().getUndertowOptions().get(UndertowOptions.ENABLE_RFC6265_COOKIE_VALIDATION, UndertowOptions.DEFAULT_ENABLE_RFC6265_COOKIE_VALIDATION)) {
            if (cookie.getValue() != null && !cookie.getValue().isEmpty()) {
                Rfc6265CookieSupport.validateCookieValue(cookie.getValue());
            }
            if (cookie.getPath() != null && !cookie.getPath().isEmpty()) {
                Rfc6265CookieSupport.validatePath(cookie.getPath());
            }
            if (cookie.getDomain() != null && !cookie.getDomain().isEmpty()) {
                Rfc6265CookieSupport.validateDomain(cookie.getDomain());
            }
        }
        if (responseCookies == null) {
            responseCookies = new TreeMap<>(); //hashmap is slow to allocate in JDK7
        }
        responseCookies.put(cookie.getName(), cookie);
        return this;
    }