protected String addParameters(String path, Map<String, String> parameters) {
        if (path == null) {
            path = "";
        }
        StringBuffer sb = new StringBuffer(path);
        if (parameters != null && parameters.size() > 0) {
            try {
                boolean hasParameters = path.indexOf("?") >= 0;
                if (!hasParameters) {
                    sb.append('?');
                }
                for (String key : parameters.keySet()) {
                    String value = parameters.get(key);
                    sb.append(URLEncoder.encode(key, "UTF-8"));
                    sb.append('=');
                    sb.append(URLEncoder.encode(value, "UTF-8"));
                    sb.append('&');
                }
                sb.deleteCharAt(sb.length() - 1);// remove last '&'
            } catch (UnsupportedEncodingException aeEx) {
                throw new RuntimeException("Unsupported encoding", aeEx);
            }
        }
        return sb.toString();
    }