ttomcat-1778514358873.zip-extract/apache-tomcat-11.0.18-src/java/org/apache/tomcat/util/http/ServerCookies.java

Path
ttomcat-1778514358873.zip-extract/apache-tomcat-11.0.18-src/java/org/apache/tomcat/util/http/ServerCookies.java
Status
scanned
Type
file
Name
ServerCookies.java
Extension
.java
Programming language
Java
Mime type
text/plain
File type
ASCII text, with CRLF line terminators
Tag

      
    
Rootfs path

      
    
Size
3102 (3.0 KB)
MD5
37c9d753a058e5dbc54f26c47194c22e
SHA1
ac130bc8e96c824581ce33f02cd2cd1db1893094
SHA256
c676a01e62955e5e6f60c4f3c176317054cfa050b9f23678f8f0ebf70b1a401b
SHA512

      
    
SHA1_git
cb3770f7d91ef1bd55a76ffe2817469add57326f
Is binary

      
    
Is text
True
Is archive

      
    
Is media

      
    
Is legal

      
    
Is manifest

      
    
Is readme

      
    
Is top level

      
    
Is key file

      
    
ServerCookies.java | 3.0 KB |

/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.tomcat.util.http; import org.apache.tomcat.util.res.StringManager; /** * This class is not thread-safe. */ public class ServerCookies { private static final StringManager sm = StringManager.getManager(ServerCookies.class); private ServerCookie[] serverCookies; private int cookieCount = 0; private int limit = 200; public ServerCookies(int initialSize) { serverCookies = new ServerCookie[initialSize]; } /** * Register a new, initialized cookie. Cookies are recycled, and most of the time an existing ServerCookie object is * returned. The caller can set the name/value and attributes for the cookie. * * @return the new cookie */ public ServerCookie addCookie() { if (limit > -1 && cookieCount >= limit) { throw new IllegalArgumentException(sm.getString("cookies.maxCountFail", Integer.valueOf(limit))); } if (cookieCount >= serverCookies.length) { int newSize = limit > -1 ? Math.min(2 * cookieCount, limit) : 2 * cookieCount; ServerCookie[] scookiesTmp = new ServerCookie[newSize]; System.arraycopy(serverCookies, 0, scookiesTmp, 0, cookieCount); serverCookies = scookiesTmp; } ServerCookie c = serverCookies[cookieCount]; if (c == null) { c = new ServerCookie(); serverCookies[cookieCount] = c; } cookieCount++; return c; } public ServerCookie getCookie(int idx) { return serverCookies[idx]; } public int getCookieCount() { return cookieCount; } public void setLimit(int limit) { this.limit = limit; if (limit > -1 && serverCookies.length > limit && cookieCount <= limit) { // shrink cookie list array ServerCookie[] scookiesTmp = new ServerCookie[limit]; System.arraycopy(serverCookies, 0, scookiesTmp, 0, cookieCount); serverCookies = scookiesTmp; } } public void recycle() { for (int i = 0; i < cookieCount; i++) { serverCookies[i].recycle(); } cookieCount = 0; } }
Detected license expression
apache-2.0
Detected license expression (SPDX)
Apache-2.0
Percentage of license text
36.62
Copyrights

      
    
Holders

      
    
Authors

      
    
License detections License expression License expression SPDX
apache_2_0-4bde3f57-78aa-4201-96bf-531cba09e7de apache-2.0 Apache-2.0
URL Start line End line
http://www.apache.org/licenses/LICENSE-2.0 9 9