public RequestBodyEntity body(String body) { RequestBodyEntity b = new RequestBodyEntity(this).body(body); this.body = b; return b; }
public MultipartBody field(String name, Collection<?> value) { MultipartBody body = new MultipartBody(this).field(name, value); this.body = body; return body; }
public MultipartBody field(String name, Collection<?> collection) { for (Object current : collection) { boolean isFile = current instanceof File; field(name, current, isFile, null); } return this; }
public static JSONObject post(String urlCommand, String body) { log.trace("post: %s body: %s", urlCommand, body); HttpResponse<JsonNode> jsonResponse = null; JSONObject response = null; try { jsonResponse = Unirest.post(urlBase + urlCommand) .header("accept", "application/json") .header("content-type", "application/json") .body(body) .asJson(); } catch (UnirestException e) { log.error("post(): %s", e.getMessage()); } String responseBody = "null"; if (SX.isNotNull(jsonResponse)) { responseBody = jsonResponse.getBody().toString(); response = SXJson.makeObject(responseBody); } log.trace("post: response: %s", responseBody); return response; }
HttpEntity entity = request.getBody().getEntity(); if (async) { if (reqObj.getHeaders(CONTENT_TYPE) == null || reqObj.getHeaders(CONTENT_TYPE).length == 0) {
public MultipartBody field(String name, File file, String contentType) { return field(name, file, true, contentType); }
public MultipartBody field(String name, File file, String contentType) { MultipartBody body = new MultipartBody(this).field(name, file, contentType); this.body = body; return body; }
public MultipartBody field(String name, File file) { return field(name, file, true, null); }
public MultipartBody field(String name, Object value, String contentType) { MultipartBody body = new MultipartBody(this).field(name, (value == null) ? "" : value.toString(), contentType); this.body = body; return body; }
public MultipartBody field(String name, String value) { return field(name, value, false, null); }
public MultipartBody fields(Map<String, Object> parameters) { MultipartBody body = new MultipartBody(this); if (parameters != null) { for (Entry<String, Object> param : parameters.entrySet()) { if (param.getValue() instanceof File) { body.field(param.getKey(), (File) param.getValue()); } else { body.field(param.getKey(), (param.getValue() == null) ? "" : param.getValue().toString()); } } } this.body = body; return body; }
public MultipartBody field(String name, Object value) { return field(name, value, false, null); }
public MultipartBody field(String name, InputStream stream, ContentType contentType, String fileName) { InputStreamBody inputStreamBody = new InputStreamBody(stream, contentType, fileName); MultipartBody body = new MultipartBody(this).field(name, inputStreamBody, true, contentType.toString()); this.body = body; return body; }
public MultipartBody field(String name, String value, String contentType) { return field(name, value, false, contentType); }
public MultipartBody field(String name, Object value, boolean file) { return field(name, value, file, null); }
public MultipartBody field(String name, byte[] bytes, ContentType contentType, String fileName) { return field(name, new ByteArrayBody(bytes, contentType, fileName), true, contentType.getMimeType()); }
public MultipartBody field(String name, InputStream stream, ContentType contentType, String fileName) { return field(name, new InputStreamBody(stream, contentType, fileName), true, contentType.getMimeType()); }
public MultipartBody field(String name, byte[] bytes, String fileName) { return field(name, new ByteArrayBody(bytes, ContentType.APPLICATION_OCTET_STREAM, fileName), true, ContentType.APPLICATION_OCTET_STREAM.getMimeType()); }
public MultipartBody field(String name, InputStream stream, String fileName) { return field(name, new InputStreamBody(stream, ContentType.APPLICATION_OCTET_STREAM, fileName), true, ContentType.APPLICATION_OCTET_STREAM.getMimeType()); }