set cookie from result of handler to HttpServletResponse

@param result
return object of handler
@param response
HttpServletResponse
5023
@SuppressWarnings("unchecked")
	private void setCookie(NativeObject result, HttpServletResponse response) {
		Map<String, String> cookieMap = ScriptableObject.getTypedProperty(
				result, "cookie", Map.class);
		if (cookieMap == null) {
			return;
		}

		Iterator<Entry<String, String>> iterator = cookieMap.entrySet()
				.iterator();
		while (iterator.hasNext()) {
			String name = iterator.next().getKey();
			Cookie cookie = new Cookie(name, cookieMap.get(name));
			response.addCookie(cookie);
		}
	}
556351
public void save(HttpServletRequest req, HttpServletResponse res) {
		AuthenticationResult authResult = new AuthenticationResult(AuthResult.SUCCESS, (String) null);
		save(req, res, authResult);
		List<Cookie> cookieList = authResult.getCookies();
		if (cookieList != null && cookieList.size() > 0) {
			CookieHelper.addCookiesToResponse(cookieList, res);
		}
	}
784756
@Get("/header")
    public HttpResponse header(@Header String xArmeriaText,            /* no conversion */
                               @Header List<Integer> xArmeriaSequence, /* converted into integer */
                               Cookies cookies                         /* converted into Cookies object */)
            throws JsonProcessingException {
        return HttpResponse.of(HttpStatus.OK, MediaType.JSON_UTF_8, mapper.writeValueAsBytes(
                Arrays.asList(xArmeriaText,
                              xArmeriaSequence,
                              cookies.stream().map(Cookie::name).collect(Collectors.toList()))));
    }
1069910
public static void setCookieValue(HttpServletResponse response, String key, String value)
	{
		setCookieValue(response, key, value, "/", -1);
	}
637729
private function resultToResponse($result) : Response
	{
		switch (true) {
			// Response object
			case $result instanceof Response:
				return $result;
			// String -> transform to response
			case is_string($result) || is_numeric($result):
				return new Response($result);
			// Array -> transform to json response
			case is_array($result) || is_object($result):
				return new JsonResponse($result);
			default:
				throw new Exception('Invalid route handler return value');
		}
	}
753550
public void copyToResponse(HttpServletResponse response, byte[] alteredResponse) throws IOException {
        // character encoding
        if(this.characterEncoding != null) {
            response.setCharacterEncoding(this.characterEncoding);
        }

        // charset
        if(this.charset != null) {
            response.setCharacterEncoding(charset);
        }

        // content type
        if(this.contentType != null) {
            response.setContentType(this.contentType);
        }

        // set the status
        if(this.statusCode > 0) {
            response.setStatus(this.statusCode);
        }

        // set the locale
        if(this.locale != null) {
            response.setLocale(this.locale);
        }

        // copy and add all cookies
        if(this.cookies != null) {
            for(Cookie cookie : this.cookies) {
                response.addCookie(cookie);
            }
        }

        // copy the byte array stream and also set its length
        final OutputStream finalOut = response.getOutputStream();
        if(alteredResponse == null) {
            int length = this.outputStream.getLength();
            response.setContentLength(length);

            // write the entire byte chunk
            this.outputStream.getByteArrayOutputStream().writeTo(finalOut);
        } else {
            response.setContentLength(alteredResponse.length);
            finalOut.write(alteredResponse);
        }

        finalOut.flush();
    }
981641
private static Response join(final Response response) throws IOException {
        final StringBuilder cookies = new StringBuilder();
        for (final String header : response.head()) {
            final Matcher matcher =
                TkJoinedCookies.PTN.matcher(header);
            if (!matcher.matches()) {
                continue;
            }
            cookies.append(matcher.group(1)).append(", ");
        }
        final Response out;
        if (cookies.length() > 0) {
            out = new RsWithHeader(
                new RsWithoutHeader(response, "Set-cookie"),
                "Set-Cookie", cookies.toString()
            );
        } else {
            out = response;
        }
        return out;
    }
486498
public HttpResponse withCookie(String name, String value) {
        this.cookies.withEntry(name, value);
        return this;
    }
933046
@RequestMapping(value = "/userLogout", method = RequestMethod.GET)
    @ResponseBody
    public JsonObject<?> logout(HttpServletResponse response) {
        JsonObject<?> ret = JsonObject.create();
        CookieUtils.resetCookieValue(response, UserWebConstant.CookieKey.USERNAME.getValue());
        CookieUtils.resetCookieValue(response, UserWebConstant.CookieKey.PWDMD5.getValue());
        return ret;
    }
976494
@Override
    public void handle(T result, HttpResponse response) {
        String restoreHeader = response.getHeaders().get(Headers.RESTORE);
        if (restoreHeader != null) {
            result.setRestoreExpirationTime(parseDate(restoreHeader));
            Boolean onGoingRestore = parseBoolean(restoreHeader);
            if (onGoingRestore != null) {
                result.setOngoingRestore(onGoingRestore);
            }
        }
    }
168871
@Override
    public void addSSOCookiesToResponse(Subject subject, HttpServletRequest req, HttpServletResponse resp) {
        if (!allowToAddCookieToResponse(req))
            return;

        addJwtSsoCookiesToResponse(subject, req, resp);

        if (!JwtSSOTokenHelper.shouldAlsoIncludeLtpaCookie()) {
            return;
        }

        SingleSignonToken ssoToken = getDefaultSSOTokenFromSubject(subject);
        if (ssoToken == null) {
            return;
        }

        byte[] ssoTokenBytes = ssoToken.getBytes();
        if (ssoTokenBytes == null) {
            return;
        }

        ByteArray cookieBytes = new ByteArray(ssoTokenBytes);
        String cookieByteString = cookieByteStringCache.get(cookieBytes);
        if (cookieByteString == null) {
            cookieByteString = StringUtil.toString(Base64Coder.base64Encode(ssoTokenBytes));
            updateCookieCache(cookieBytes, cookieByteString);
        }

        Cookie ssoCookie = createCookie(req, cookieByteString);
        resp.addCookie(ssoCookie);
    }
562815
public void setResult(Result result) throws IllegalArgumentException
  {

    if (null == result)
      throw new IllegalArgumentException(XSLMessages.createMessage(XSLTErrorResources.ER_RESULT_NULL, null)); //"result should not be null");

    try
    {
//      ContentHandler handler =
//        m_transformer.createResultContentHandler(result);
//      m_transformer.setContentHandler(handler);
        SerializationHandler xoh = 
            m_transformer.createSerializationHandler(result);
        m_transformer.setSerializationHandler(xoh);
    }
    catch (javax.xml.transform.TransformerException te)
    {
      throw new IllegalArgumentException(XSLMessages.createMessage(XSLTErrorResources.ER_RESULT_COULD_NOT_BE_SET, null)); //"result could not be set");
    }

    m_result = result;
  }
1325280
private void performAdjustCookies(HttpServletRequest request, HttpServletResponse response) throws Exception {

		boolean loggedIn = false;
		User user = null;
		try {
			Cookie cookie = getCookieFromRequest(request);
			if( null != cookie ) {
				user = CookieAuthentication.verifyCookieString(userRepository, cookie.getValue());
				loggedIn = true;
			}
		} catch(Exception e) {
			// Ignore
		}
		
		if( null == user ) {
			user = userRepository.getDefaultUser();
		}
		
		acceptRequest(response, loggedIn, user);
	}
309603
@Override
	public void removeRequest(HttpServletRequest request, HttpServletResponse response) {
		HttpUtils.removeStateParam(Config.RETURNTO_COOKIE, request, response);
	}
1355994
public void setResult(Object result) {
        if (resultSent) {
            throw new RuntimeException("You can only set the result once.");
        }
        this.resultSent = true;
        Channel channel = this.channel.get();
        if (channel == null) {
            log.warn("The client is no longer connected.");
            return;
        }
        call.setResult(result);
        Invoke reply = new Invoke();
        reply.setCall(call);
        reply.setTransactionId(transactionId);
        channel.write(reply);
        channel.getConnection().unregisterDeferredResult(this);
    }
889013
public static void failureCookie(HttpServletRequest request, HttpServletResponse response,
            String name, String domain,String contextPath) {
        if (request != null && response != null) {
            addCookie(request, response, name, null, domain, contextPath, 0,true);
        }
    }
331212
public final void request(Result<I> result)
  {
    I instance = _instance;
    
    if (instance != null && _lifecycle.isActive() && ! isModified()) {
      result.ok(instance);
    }
    else if (_lifecycle.isDestroyed()) {
      result.ok(null);
    }
    else {
      _strategy.request(this, result);
    }
  }