1. Project Clover database Sat Feb 2 2019 06:45:20 CET
  2. Package com.xpn.xwiki.web

File XWikiServletRequest.java

 

Coverage histogram

../../../../img/srcFileCovDistChart6.png
72% of files have more coverage

Code metrics

12
19
9
1
112
66
16
0.84
2.11
9
1.78

Classes

Class Line # Actions
XWikiServletRequest 35 19 0% 16 17
0.57557.5%
 

Contributing tests

This file is covered by 4 tests. .

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package com.xpn.xwiki.web;
21   
22    import javax.servlet.http.Cookie;
23    import javax.servlet.http.HttpServletRequest;
24    import javax.servlet.http.HttpServletRequestWrapper;
25   
26    import org.apache.struts.upload.MultipartRequestWrapper;
27   
28    import com.xpn.xwiki.util.Util;
29   
30    /**
31    * {@link HttpServletRequest} implementation with XWiki related specific behavior.
32    *
33    * @version $Id: dd978e18d7b3933aaa2e1d4d8ab06f88148a13c8 $
34    */
 
35    public class XWikiServletRequest extends HttpServletRequestWrapper implements XWikiRequest
36    {
 
37  188092 toggle public XWikiServletRequest(HttpServletRequest request)
38    {
39    // Passing null to #XWikiServletRequest(HttpServletRequest) used partially work so keeping it working to be safe
40  188060 super(request != null ? request : new XWikiServletRequestStub());
41    }
42   
43    // XWikiRequest
44   
 
45  639169 toggle @Override
46    public String get(String name)
47    {
48  639201 return getRequest().getParameter(name);
49    }
50   
 
51  401456 toggle @Override
52    public HttpServletRequest getHttpServletRequest()
53    {
54  401563 return (HttpServletRequest) getRequest();
55    }
56   
 
57  12507 toggle @Override
58    public Cookie getCookie(String cookieName)
59    {
60  12507 return Util.getCookie(cookieName, this);
61    }
62   
63    // HttpServletRequest
64   
 
65  192332 toggle @Override
66    public StringBuffer getRequestURL()
67    {
68  192357 HttpServletRequest request = getHttpServletRequest();
69  192335 StringBuffer requestURL = request.getRequestURL();
70  192363 if ((requestURL == null) && (request instanceof MultipartRequestWrapper)) {
71  0 requestURL = ((HttpServletRequest) ((MultipartRequestWrapper) request).getRequest()).getRequestURL();
72    }
73   
74  192344 return requestURL;
75    }
76   
 
77  5402070 toggle @Override
78    public String getParameter(String s)
79    {
80    // Some servlet containers don't support passing null so we need to handle it.
81  5402386 return s != null ? getRequest().getParameter(s) : null;
82    }
83   
 
84  17088 toggle @Override
85    public String[] getParameterValues(String s)
86    {
87    // Some servlet containers don't support passing null so we need to handle it.
88  17093 return s != null ? getRequest().getParameterValues(s) : null;
89    }
90   
 
91  0 toggle @Override
92    public String getRemoteAddr()
93    {
94  0 HttpServletRequest request = getHttpServletRequest();
95  0 if (request.getHeader("x-forwarded-for") != null) {
96  0 return request.getHeader("x-forwarded-for");
97    }
98   
99  0 return request.getRemoteAddr();
100    }
101   
 
102  0 toggle @Override
103    public String getRemoteHost()
104    {
105  0 HttpServletRequest request = getHttpServletRequest();
106  0 if (request.getHeader("x-forwarded-for") != null) {
107  0 return request.getHeader("x-forwarded-for");
108    }
109   
110  0 return request.getRemoteHost();
111    }
112    }