/** * Set up the request parameters or POST payload. */ private void buildRequest() throws IOException { if (isMethodWithBody()) { uc.setDoOutput(true); uc.setRequestProperty("Content-type", contentType); if (body == null) { Map json = new HashMap(); for (Entry e : args) { json.put(e.key, e.value); } MAPPER.writeValue(uc.getOutputStream(), json); } else { try { byte[] bytes = new byte[32768]; int read = 0; while ((read = body.read(bytes)) != -1) { uc.getOutputStream().write(bytes, 0, read); } } finally { body.close(); } } } }
/** * Set up the request parameters or POST payload. */ private void buildRequest() throws IOException { if (isMethodWithBody()) { uc.setDoOutput(true); if (body == null) { uc.setRequestProperty("Content-type", defaultString(contentType,"application/json")); Map json = new HashMap(); for (Entry e : args) { json.put(e.key, e.value); } MAPPER.writeValue(uc.getOutputStream(), json); } else { uc.setRequestProperty("Content-type", defaultString(contentType,"application/x-www-form-urlencoded")); try { byte[] bytes = new byte[32768]; int read; while ((read = body.read(bytes)) != -1) { uc.getOutputStream().write(bytes, 0, read); } } finally { body.close(); } } } }
/** * Set up the request parameters or POST payload. */ private void buildRequest() throws IOException { if (isMethodWithBody()) { uc.setDoOutput(true); if (body == null) { uc.setRequestProperty("Content-type", defaultString(contentType,"application/json")); Map json = new HashMap(); for (Entry e : args) { json.put(e.key, e.value); } MAPPER.writeValue(uc.getOutputStream(), json); } else { uc.setRequestProperty("Content-type", defaultString(contentType,"application/x-www-form-urlencoded")); try { byte[] bytes = new byte[32768]; int read; while ((read = body.read(bytes)) != -1) { uc.getOutputStream().write(bytes, 0, read); } } finally { body.close(); } } } }
@SuppressFBWarnings("SBSC_USE_STRINGBUFFER_CONCATENATION") private <T> T _to(String tailApiUrl, Class<T> type, T instance) throws IOException { if (!isMethodWithBody() && !args.isEmpty()) { boolean questionMarkFound = tailApiUrl.indexOf('?') != -1; tailApiUrl += questionMarkFound ? '&' : '?';
@SuppressFBWarnings("SBSC_USE_STRINGBUFFER_CONCATENATION") private <T> T _to(String tailApiUrl, Class<T> type, T instance) throws IOException { if (!isMethodWithBody() && !args.isEmpty()) { boolean questionMarkFound = tailApiUrl.indexOf('?') != -1; tailApiUrl += questionMarkFound ? '&' : '?';