/** * Append given parameters to the query string of the url * * @param url the url to append parameters to * @param params any map * @return new url with parameters on query string */ public static String appendParametersToQueryString(String url, Map<String, String> params) { String queryString = URLUtils.formURLEncodeMap(params); if (queryString.length() == 0) return url; // Check if there are parameters in the url already and use '&' instead of '?' url += url.indexOf(QUERY_STRING_SEPARATOR) != -1 ? PARAM_SEPARATOR : QUERY_STRING_SEPARATOR; url += queryString; return url; }
byte[] getByteBodyContents() { if (bytePayload != null) return bytePayload; String body = null; if (payload != null) { body = payload; } else if (files.isEmpty()) { body = URLUtils.formURLEncodeMap(bodyParams); } else { byte res[] = null; try { res = URLUtils.doFormDataEncode(bodyParams, files, boundary).toByteArray(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return res; } try { return body.getBytes(getCharset()); } catch (UnsupportedEncodingException uee) { throw new OAuthException("Unsupported Charset: " + getCharset(), uee); } }