MCPcopy Create free account
hub / github.com/dianping/cat / getRequestURI

Method getRequestURI

integration/URL/CatFilter.java:206–258  ·  view source on GitHub ↗
(HttpServletRequest req)

Source from the content-addressed store, hash-verified

204 }
205
206 private String getRequestURI(HttpServletRequest req) {
207 String url = req.getRequestURI();
208 int length = url.length();
209 StringBuilder sb = new StringBuilder(length);
210
211 for (int index = 0; index < length;) {
212 char c = url.charAt(index);
213
214 if (c == SPLIT && index < length - 1) {
215 sb.append(c);
216
217 StringBuilder nextSection = new StringBuilder();
218 boolean isNumber = false;
219 boolean first = true;
220
221 for (int j = index + 1; j < length; j++) {
222 char next = url.charAt(j);
223
224 if ((first || isNumber == true) && next != SPLIT) {
225 isNumber = isNumber(next);
226 first = false;
227 }
228
229 if (next == SPLIT) {
230 if (isNumber) {
231 sb.append("{num}");
232 } else {
233 sb.append(nextSection.toString());
234 }
235 index = j;
236
237 break;
238 } else if (j == length - 1) {
239 if (isNumber) {
240 sb.append("{num}");
241 } else {
242 nextSection.append(next);
243 sb.append(nextSection.toString());
244 }
245 index = j + 1;
246 break;
247 } else {
248 nextSection.append(next);
249 }
250 }
251 } else {
252 sb.append(c);
253 index++;
254 }
255 }
256
257 return sb.toString();
258 }
259
260 @Override
261 public void handle(Context ctx) throws IOException, ServletException {

Callers 9

handleMethod · 0.95
uriMethod · 0.45
ContextMethod · 0.45
beginLogMethod · 0.45
beginLogMethod · 0.45
getRequestMethodInfoMethod · 0.45
doFilterMethod · 0.45
getOriginalUrlMethod · 0.45
logRequestPayloadMethod · 0.45

Calls 4

isNumberMethod · 0.95
lengthMethod · 0.45
appendMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected