![JAR search and dependency download from the Maven repository](/logo.png)
org.glowroot.instrumentation.servlet.boot.ResponseHeaderComponent Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of instrumentation-servlet Show documentation
Show all versions of instrumentation-servlet Show documentation
Instrumentation for the Servlet API
/*
* Copyright 2014-2019 the original author or authors.
*
* Licensed 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.glowroot.instrumentation.servlet.boot;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.TimeZone;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.CopyOnWriteArrayList;
import org.glowroot.instrumentation.api.Logger;
import org.glowroot.instrumentation.api.checker.MonotonicNonNull;
import org.glowroot.instrumentation.api.checker.Nullable;
// this class is thread safe since it is part of the thread safe ServletMessageSupplier (see comment
// in ServletMessageSupplier for details why)
class ResponseHeaderComponent {
private static final Logger logger = Logger.getLogger(ServletMessageSupplier.class);
// HTTP response header date format (RFC 1123)
// also see org.apache.tomcat.util.http.FastHttpDateFormat
private static final SimpleDateFormat responseHeaderDateFormat =
new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.US);
static {
// all HTTP dates are on GMT
responseHeaderDateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
}
// map key is uppercase for case-insensitivity
private @MonotonicNonNull ConcurrentMap responseHeaders;
synchronized Map getMapOfStrings() {
if (responseHeaders == null) {
return Collections.emptyMap();
}
// lazy format int and date headers as strings since this method is only called if
// it is really needed (for storage or display of active trace)
Map responseHeaderStrings = new HashMap();
for (ResponseHeader responseHeader : responseHeaders.values()) {
String name = responseHeader.getName();
List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy