/** * Set the body of the request. * * @param body The body. * @return the modified builder */ protected RequestBuilder body(RequestBody body) { if (body == null || body.as(Object.class) == null) { // assume null signifies no body; RequestBody is a wrapper for the actual body content headers(getHeaders().remove(HeaderNames.CONTENT_LENGTH).remove(HeaderNames.TRANSFER_ENCODING)); } else { if (!getHeaders().get(HeaderNames.TRANSFER_ENCODING).isPresent()) { final MultipartFormData<?> multipartFormData = body.asMultipartFormData(); if (multipartFormData != null) { header(HeaderNames.CONTENT_LENGTH, Long.toString(calcMultipartFormDataBodyLength(multipartFormData))); } else { int length = body.asBytes().length(); header(HeaderNames.CONTENT_LENGTH, Integer.toString(length)); } } } req = req.withBody(body); return this; }
/** * Set the body of the request. * * @param body The body. * @return the modified builder */ protected RequestBuilder body(RequestBody body) { if (body == null || body.as(Object.class) == null) { // assume null signifies no body; RequestBody is a wrapper for the actual body content headers(getHeaders().remove(HeaderNames.CONTENT_LENGTH).remove(HeaderNames.TRANSFER_ENCODING)); } else { if (!getHeaders().get(HeaderNames.TRANSFER_ENCODING).isPresent()) { final MultipartFormData<?> multipartFormData = body.asMultipartFormData(); if (multipartFormData != null) { header(HeaderNames.CONTENT_LENGTH, Long.toString(calcMultipartFormDataBodyLength(multipartFormData))); } else { int length = body.asBytes().length(); header(HeaderNames.CONTENT_LENGTH, Integer.toString(length)); } } } req = req.withBody(body); return this; }
/** * Set the body of the request. * * @param body The body. * @return the modified builder */ protected RequestBuilder body(RequestBody body) { if (body == null || body.as(Object.class) == null) { // assume null signifies no body; RequestBody is a wrapper for the actual body content headers(getHeaders().remove(HeaderNames.CONTENT_LENGTH).remove(HeaderNames.TRANSFER_ENCODING)); } else { if (!getHeaders().get(HeaderNames.TRANSFER_ENCODING).isPresent()) { final MultipartFormData<?> multipartFormData = body.asMultipartFormData(); if (multipartFormData != null) { header(HeaderNames.CONTENT_LENGTH, Long.toString(calcMultipartFormDataBodyLength(multipartFormData))); } else { int length = body.asBytes().length(); header(HeaderNames.CONTENT_LENGTH, Integer.toString(length)); } } } req = req.withBody(body); return this; }
public static Result getmail() { Http.Request req = Controller.request(); Http.RequestBody reqbody = req.body(); System.out.println("AS TEXT: " + reqbody.asText()); byte[] rawbuff = reqbody.as(byte[].class); String rawstr = new String(rawbuff); System.out.println("REQUEST: " + rawstr); }
/** * The request content as Json. * * @return The request content as Json. */ public JsonNode asJson() { return as(JsonNode.class); }
/** * The request content as XML. * * @return The request content as XML. */ public Document asXml() { return as(Document.class); }
/** * The request content as Array bytes. * * @return The request content as Array bytes. */ public RawBuffer asRaw() { return as(RawBuffer.class); }
/** * The request content as XML. * * @return The request content as XML. */ public Document asXml() { return as(Document.class); }
/** * The request content parsed as multipart form data. * * @param <A> the file type (e.g. play.api.libs.Files.TemporaryFile) * @return the content parsed as multipart form data */ public <A> MultipartFormData<A> asMultipartFormData() { return as(MultipartFormData.class); }
/** * The request content as text. * * @return The request content as text. */ public String asText() { return as(String.class); }
/** * The request content as Array bytes. * * @return The request content as Array bytes. */ public RawBuffer asRaw() { return as(RawBuffer.class); }
/** * The request content as Json. * * @return The request content as Json. */ public JsonNode asJson() { return as(JsonNode.class); }
/** * The request content as text. * * @return The request content as text. */ public String asText() { return as(String.class); }
/** * The request content parsed as multipart form data. * * @param <A> the file type (e.g. play.api.libs.Files.TemporaryFile) * @return the content parsed as multipart form data */ public <A> MultipartFormData<A> asMultipartFormData() { return as(MultipartFormData.class); }
/** * The request content as Json. * * @return The request content as Json. */ public JsonNode asJson() { return as(JsonNode.class); }
/** * The request content as XML. * * @return The request content as XML. */ public Document asXml() { return as(Document.class); }
/** * The request content parsed as multipart form data. * * @param <A> the file type (e.g. play.api.libs.Files.TemporaryFile) * @return the content parsed as multipart form data */ public <A> MultipartFormData<A> asMultipartFormData() { return as(MultipartFormData.class); }
/** * The request content as Array bytes. * * @return The request content as Array bytes. */ public RawBuffer asRaw() { return as(RawBuffer.class); }
/** * The request content as text. * * @return The request content as text. */ public String asText() { return as(String.class); }