Coverage Report - org.webslinger.servlet.HttpServletRequestConfig
 
Classes in this File Line Coverage Branch Coverage Complexity
HttpServletRequestConfig
35%
17/48
0%
0/1
0
 
 1  
 package org.webslinger.servlet;
 2  
 
 3  
 import java.io.BufferedReader;
 4  
 import java.io.IOException;
 5  
 import java.io.InputStream;
 6  
 import java.io.InputStreamReader;
 7  
 import java.io.ObjectInputStream;
 8  
 import java.io.ObjectOutputStream;
 9  
 import java.io.ObjectStreamException;
 10  
 import java.io.Serializable;
 11  
 import java.security.Principal;
 12  
 import java.util.Collection;
 13  
 import java.util.HashMap;
 14  
 import java.util.Locale;
 15  
 import java.util.HashSet;
 16  
 import java.util.Map;
 17  
 import java.util.Set;
 18  
 import javax.servlet.ServletInputStream;
 19  
 import javax.servlet.ServletRequest;
 20  
 import javax.servlet.RequestDispatcher;
 21  
 import javax.servlet.http.Cookie;
 22  
 
 23  
 public class HttpServletRequestConfig extends ServletRequestConfig {
 24  
     protected String authType;
 25  
     protected String contextPath;
 26  
     protected final HttpHeaders headers;
 27  526
     protected String method = "GET";
 28  
     protected String remoteUser;
 29  
     protected String sessionId;
 30  
     protected Principal user;
 31  
 
 32  526
     protected transient Cookie[] cookies = new Cookie[0];
 33  526
     protected Map<String, Cookie> cookieMap = new HashMap<String, Cookie>();
 34  
 
 35  
     private Object readResolve() throws ObjectStreamException {
 36  0
         cookies = cookieMap.values().toArray(new Cookie[cookieMap.size()]);
 37  0
         return this;
 38  
     }
 39  
 
 40  
     public HttpServletRequestConfig() {
 41  0
         this("GET", "");
 42  0
     }
 43  
 
 44  
     public HttpServletRequestConfig(HttpHeaders headers) {
 45  0
         this("GET", "", headers);
 46  0
     }
 47  
 
 48  
     public HttpServletRequestConfig(String method) {
 49  0
         this(method, "");
 50  0
     }
 51  
 
 52  
     public HttpServletRequestConfig(String method, HttpHeaders headers) {
 53  526
         this(method, "", headers);
 54  526
     }
 55  
 
 56  
     public HttpServletRequestConfig(String method, String contextPath) {
 57  0
         this(method, contextPath, new HttpHeadersImpl());
 58  0
     }
 59  
 
 60  526
     public HttpServletRequestConfig(String method, String contextPath, HttpHeaders headers) {
 61  526
         setMethod(method);
 62  526
         setContextPath(contextPath);
 63  526
         this.headers = headers;
 64  526
     }
 65  
 
 66  
     public void addCookie(Cookie cookie) {
 67  0
         cookieMap.put(cookie.getName(), cookie);
 68  0
         cookies = (Cookie[]) cookieMap.values().toArray(new Cookie[cookieMap.size()]);
 69  0
     }
 70  
 
 71  
     public void removeCookie(String name) {
 72  0
         cookieMap.remove(name);
 73  0
         if (cookieMap.size() == cookies.length) return;
 74  0
         cookies = (Cookie[]) cookieMap.values().toArray(new Cookie[cookieMap.size()]);
 75  0
     }
 76  
 
 77  
     public Cookie[] getCookies() {
 78  0
         return cookies;
 79  
     }
 80  
 
 81  
     public Map getCookieMap() {
 82  0
         return cookieMap;
 83  
     }
 84  
 
 85  
     public HttpHeaders getHeaders() {
 86  230
         return headers;
 87  
     }
 88  
 
 89  
     public void setAuthType(String authType) {
 90  0
         this.authType = authType;
 91  0
     }
 92  
 
 93  
     public String getAuthType() {
 94  0
         return authType;
 95  
     }
 96  
 
 97  
     public void setContextPath(String contextPath) {
 98  526
         this.contextPath = contextPath;
 99  526
     }
 100  
 
 101  
     public String getContextPath() {
 102  0
         return contextPath;
 103  
     }
 104  
 
 105  
     public void setMethod(String method) {
 106  526
         this.method = method;
 107  526
     }
 108  
 
 109  
     public String getMethod() {
 110  0
         return method;
 111  
     }
 112  
 
 113  
     public void setRemoteUser(String remoteUser) {
 114  0
         this.remoteUser = remoteUser;
 115  0
     }
 116  
 
 117  
     public String getRemoteUser() {
 118  0
         return remoteUser;
 119  
     }
 120  
 
 121  
     public void setSessionId(String sessionId) {
 122  0
         this.sessionId = sessionId;
 123  0
     }
 124  
 
 125  
     public String getSessionId() {
 126  0
         return sessionId;
 127  
     }
 128  
 
 129  
     public void setUserPrincipal(Principal user) {
 130  526
         this.user = user;
 131  526
     }
 132  
 
 133  
     public Principal getUserPrincipal() {
 134  0
         return user;
 135  
     }
 136  
 }