HttpMessageType

final class HttpMessageType[T <: HttpMessage](message: T) extends AnyVal

Adds extension methods to HttpMessage for building messages with various content types.

class AnyVal
trait Matchable
class Any

Value members

Concrete methods

def setFileBody(file: File)(implicit ev: T <:< MessageBuilder[T]): T

Creates new message with content from supplied file as message body.

Creates new message with content from supplied file as message body.

After adding body to message, the Content-Type header is set based on file type, and Content-Length is set to file size.

Value Params
file

message body

def setFormBody(data: Map[String, Seq[String]])(implicit ev: T <:< MessageBuilder[T]): T

Creates new message with supplied form data as message body.

Creates new message with supplied form data as message body.

After adding body to message, the Content-Type header is set to application/x-www-form-urlencoded, and Content-Length is set to length of encoded form data.

Value Params
data

message body

def setFormBody(data: Seq[(String, String)])(implicit ev: T <:< MessageBuilder[T]): T

Creates new message with supplied form data as message body.

Creates new message with supplied form data as message body.

After adding body to message, the Content-Type header is set to application/x-www-form-urlencoded, and Content-Length is set to length of encoded form data.

Value Params
data

message body

def setFormBody(one: (String, String), more: (String, String)*)(implicit ev: T <:< MessageBuilder[T]): T

Creates new message with supplied form data as message body.

Creates new message with supplied form data as message body.

After adding body to message, the Content-Type header is set to application/x-www-form-urlencoded, and Content-Length is set to length of encoded form data.

Value Params
more

additional form data

one

form data

def setFormBody(query: QueryString)(implicit ev: T <:< MessageBuilder[T]): T

Creates new message with supplied query string as message body.

Creates new message with supplied query string as message body.

After adding body to message, the Content-Type header is set to application/x-www-form-urlencoded, and Content-Length is set to length of encoded query string.

Value Params
query

message body

def setMultipartBody(multipart: Multipart)(implicit ev: T <:< MessageBuilder[T]): T

Creates new message with supplied multipart as message body.

Creates new message with supplied multipart as message body.

After adding body to message, the Content-Type header is set to multipart/form-data with a boundary parameter whose value is used to delimit parts in encoded message body.

Value Params
multipart

message body

def setMultipartBody(parts: Seq[Part])(implicit ev: T <:< MessageBuilder[T]): T

Creates new message with supplied parts as message body, with the parts encoded as multipart form data.

Creates new message with supplied parts as message body, with the parts encoded as multipart form data.

After adding body to message, the Content-Type header is set to multipart/form-data with a boundary parameter whose value is used to delimit parts in encoded message body.

Value Params
parts

message body

def setMultipartBody(one: Part, more: Part*)(implicit ev: T <:< MessageBuilder[T]): T

Creates new message with supplied parts as message body, with the parts encoded as multipart form data.

Creates new message with supplied parts as message body, with the parts encoded as multipart form data.

After adding body to message, the Content-Type header is set to multipart/form-data with a boundary parameter whose value is used to delimit parts in encoded message body.

Value Params
more

additional parts

one

part

def setTextBody(text: String, charset: String)(implicit ev: T <:< MessageBuilder[T]): T

Creates new message with supplied text as message body.

Creates new message with supplied text as message body.

After adding body to message, the Content-Type header is set to text/plain with its charset parameter set accordingly, and Content-Length is set to length of encoded characters.

Value Params
charset

character set

text

message body