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

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

      
    
Rootfs path

      
    
Size
2130 (2.1 KB)
MD5
1c99f56413245a0c557fb7893ed9b2f2
SHA1
e09f375758d6520b985575eec088ee76564338b1
SHA256
fb86e772afcb4972def2559e2ac300db2c5a03df5003bdd72ac0226d5d0fbd69
SHA512

      
    
SHA1_git
28f30ef51654cee9fb07cf1d010e85dafb81d01b
Is binary

      
    
Is text
True
Is archive

      
    
Is media

      
    
Is legal

      
    
Is manifest

      
    
Is readme

      
    
Is top level

      
    
Is key file

      
    
HeaderUtil.java | 2.1 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; public class HeaderUtil { /** * Converts an HTTP header line in byte form to a printable String. Bytes corresponding to visible ASCII characters * will be converted to those characters. All other bytes (0x00 to 0x1F, 0x7F to 0xFF) will be represented in 0xNN * form. * * @param bytes Contains an HTTP header line * @param offset The start position of the header line in the array * @param len The length of the HTTP header line * * @return A String with non-printing characters replaced by the 0xNN equivalent */ public static String toPrintableString(byte[] bytes, int offset, int len) { StringBuilder result = new StringBuilder(); for (int i = offset; i < offset + len; i++) { char c = (char) (bytes[i] & 0xFF); if (c < 0x20 || c > 0x7E) { result.append("0x"); result.append(Character.forDigit((c >> 4) & 0xF, 16)); result.append(Character.forDigit((c) & 0xF, 16)); } else { result.append(c); } } return result.toString(); } private HeaderUtil() { // Utility class. Hide default constructor. } }
Detected license expression
apache-2.0
Detected license expression (SPDX)
Apache-2.0
Percentage of license text
44.4
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