HttpMethod (final String requestUrl) { int n = requestUrl.indexOf('?'); if (n == -1) { return new PostMethod(requestUrl); } PostMethod postMethod = new PostMethod(requestUrl.substring(0, n)); String[] queryParams = requestUrl.substring(n + 1).split("&"); postMethod.addParameters(ContainerUtil.map2Array(queryParams, NameValuePair.class, s -> { String[] nv = s.split("="); if (nv.length == 1) { return new NameValuePair(nv[0], ""); } return new NameValuePair(nv[0], nv[1]); })); return postMethod; }