1   /**
2    * Logback: the reliable, generic, fast and flexible logging framework.
3    * Copyright (C) 1999-2015, QOS.ch. All rights reserved.
4    *
5    * This program and the accompanying materials are dual-licensed under
6    * either the terms of the Eclipse Public License v1.0 as published by
7    * the Eclipse Foundation
8    *
9    *   or (per the licensee's choosing)
10   *
11   * under the terms of the GNU Lesser General Public License version 2.1
12   * as published by the Free Software Foundation.
13   */
14  package ch.qos.logback.access.common.spi;
15  
16  import ch.qos.logback.core.spi.DeferredProcessingAware;
17  
18  import jakarta.servlet.http.Cookie;
19  import jakarta.servlet.http.HttpServletRequest;
20  import jakarta.servlet.http.HttpServletResponse;
21  import java.util.Enumeration;
22  import java.util.List;
23  import java.util.Map;
24  
25  // Contributors:  Joern Huxhorn (see also bug #110)
26  
27  /**
28   * <p>This class is the internal representation of events to be logged.
29   * </p>
30   *
31   * <p>When the HTTP container wishes to log an HTTP access event, then
32   * an instance of this class is created. This instance is passed around
33   * to the different logback components.
34   * </p>
35   *
36   * <p>Put differently, the logback-access project revolves around this interface.</p>
37   *
38   * @author Ceki G&uuml;lc&uuml;
39   * @author S&eacute;bastien Pennec
40   * @author J&ouml;rn Huxhorn
41   */
42  public interface IAccessEvent extends DeferredProcessingAware {
43  
44      String NA = "-";
45      int SENTINEL = -1;
46  
47      /**
48       * Returns the underlying HttpServletRequest. After serialization the returned
49       * value will be null.
50       *
51       * @return
52       */
53      HttpServletRequest getRequest();
54  
55      /**
56       * Returns the underlying HttpServletResponse. After serialization the returned
57       * value will be null.
58       *
59       * @return
60       */
61      HttpServletResponse getResponse();
62  
63      /**
64       * The number of milliseconds elapsed from 1/1/1970 until logging event was
65       * created.
66       */
67      long getTimeStamp();
68  
69      /**
70       * The sequence number associated with this event.
71       * 
72       * <p>
73       * Sequence numbers, if present, should be increasing monotonically.
74       * 
75       * @since 1.3.0
76       */
77  
78      long getSequenceNumber();
79  
80      /**
81       * The time elapsed between receiving the request and logging it in
82       * milliseconds.
83       */
84      long getElapsedTime();
85  
86      /**
87       * The number of seconds elapsed between receiving the request and logging it.
88       */
89      long getElapsedSeconds();
90  
91      String getRequestURI();
92  
93      /**
94       * The first line of the request.
95       */
96      String getRequestURL();
97  
98      String getRemoteHost();
99  
100     String getRemoteUser();
101 
102     String getProtocol();
103 
104     String getMethod();
105 
106     String getServerName();
107 
108     String getSessionID();
109 
110     void setThreadName(String threadName);
111 
112     String getThreadName();
113 
114     String getQueryString();
115 
116     String getRemoteAddr();
117 
118     String getRequestHeader(String key);
119 
120     Enumeration<String> getRequestHeaderNames();
121 
122     Map<String, String> getRequestHeaderMap();
123 
124     Map<String, String[]> getRequestParameterMap();
125 
126     String getAttribute(String key);
127 
128     String[] getRequestParameter(String key);
129 
130     /**
131      * <p>Return a list of cookies in the httpRequest. The list is immutable and is created if
132      * it did not exist previously.
133      * </p>
134      *
135      * <p>The default implementation returns an immutable empty list.
136      * </p>
137      *
138      * @return an immutable list of cookies in the httpRequest, the returned list can be empty but not null
139      * @since version 2.0.2
140      */
141     default List<Cookie> getCookies() {
142        return  List.of();
143     }
144 
145     String getCookie(String key);
146 
147     long getContentLength();
148 
149     int getStatusCode();
150 
151     String getRequestContent();
152 
153     String getResponseContent();
154 
155     int getLocalPort();
156 
157     ServerAdapter getServerAdapter();
158 
159     String getResponseHeader(String key);
160 
161     Map<String, String> getResponseHeaderMap();
162 
163     List<String> getResponseHeaderNameList();
164 }