/** * 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; }
/** * @param host sets the host in the header * @return the builder instance */ public RequestBuilder host(String host) { header(HeaderNames.HOST, host); return this; }
/** * Set the body of the request. * * @param body the body * @param contentType Content-Type header value * @return the modified builder */ protected RequestBuilder body(RequestBody body, String contentType) { header(HeaderNames.CONTENT_TYPE, contentType); body(body); return this; }
/** * Sets the cookies in the header. * @param cookies the cookies in a Scala sequence */ private void cookies(Seq<play.api.mvc.Cookie> cookies) { String cookieHeader = header(HeaderNames.COOKIE); String value = play.api.mvc.Cookies$.MODULE$.mergeCookieHeader(cookieHeader != null ? cookieHeader : "", cookies); header(HeaderNames.COOKIE, value); }
/** * @param host sets the host in the header * @return the builder instance */ public RequestBuilder host(String host) { header(HeaderNames.HOST, host); return this; }
/** * Set a AnyContent to this request. * @param anyContent the AnyContent * @param contentType Content-Type header value */ protected RequestBuilder body(AnyContent anyContent, String contentType) { header("Content-Type", contentType); body(anyContent); return this; }
/** * Set the body of the request. * * @param body the body * @param contentType Content-Type header value * @return the modified builder */ protected RequestBuilder body(RequestBody body, String contentType) { header(HeaderNames.CONTENT_TYPE, contentType); body(body); return this; }
/** * @return the host name from the header */ public String host() { return header(HeaderNames.HOST); }
/** * @param host sets the host in the header * @return the builder instance */ public RequestBuilder host(String host) { header(HeaderNames.HOST, host); return this; }
/** * @param host sets the host in the header * @return the builder instance */ public RequestBuilder host(String host) { header(HeaderNames.HOST, host); return this; }
/** * @return the cookies in Scala instances */ private play.api.mvc.Cookies scalaCookies() { String cookieHeader = header(HeaderNames.COOKIE); scala.Option<String> cookieHeaderOpt = scala.Option.apply(cookieHeader); return play.api.mvc.Cookies$.MODULE$.fromCookieHeader(cookieHeaderOpt); }
/** * Set the body of the request. * * @param body the body * @param contentType Content-Type header value * @return the modified builder */ protected RequestBuilder body(RequestBody body, String contentType) { header(HeaderNames.CONTENT_TYPE, contentType); body(body); return this; }