@Override public Cookie[] getCookies() { if (cookies == null) { List<Cookie> list = new ArrayList<Cookie>(); String cookieStr = getHeader("Cookie"); if (VerifyUtils.isEmpty(cookieStr)) { cookies = EMPTY_COOKIE_ARR; } else { String[] c = StringUtils.split(cookieStr, ';'); for (String t : c) { int j = 0; for (int i = 0; i < t.length(); i++) { if (t.charAt(i) == '=') { j = i; break; } } if (j > 1) { String name = t.substring(0, j).trim(); String value = t.substring(j + 1).trim(); Cookie cookie = new Cookie(name, value); list.add(cookie); } else continue; } cookies = list.toArray(EMPTY_COOKIE_ARR); } } return cookies; }
@Override public Enumeration<String> getHeaders(String name) { String value = getHeader(name); final String[] values = StringUtils.split(value, ','); return new Enumeration<String>() { private int i = 0; @Override public boolean hasMoreElements() { return i < values.length; } @Override public String nextElement() { return values[i++]; } }; }
private void loadParam(String str) throws UnsupportedEncodingException { if (VerifyUtils.isNotEmpty(str)) { String[] p = StringUtils.split(str, '&'); for (String kv : p) { int i = kv.indexOf('='); if (i > 0) { String name = kv.substring(0, i); String value = kv.substring(i + 1); List<String> list = parameterMap.get(name); if (list == null) { list = new ArrayList<String>(); parameterMap.put(name, list); } list.add(URLDecoder.decode(value, characterEncoding)); } } } }