From 10edc9d4469bac8fa760befb91422cad96d838fe Mon Sep 17 00:00:00 2001 From: adamw Date: Fri, 30 Jun 2017 17:14:54 +0200 Subject: More methods --- .../scala/com/softwaremill/sttp/model/package.scala | 2 ++ .../main/scala/com/softwaremill/sttp/package.scala | 20 ++++++++++++-------- 2 files changed, 14 insertions(+), 8 deletions(-) (limited to 'core') diff --git a/core/src/main/scala/com/softwaremill/sttp/model/package.scala b/core/src/main/scala/com/softwaremill/sttp/model/package.scala index 1541398..e50426c 100644 --- a/core/src/main/scala/com/softwaremill/sttp/model/package.scala +++ b/core/src/main/scala/com/softwaremill/sttp/model/package.scala @@ -14,6 +14,8 @@ package object model { val DELETE = Method("DELETE") val OPTIONS = Method("OPTIONS") val PATCH = Method("PATCH") + val CONNECT = Method("CONNECT") + val TRACE = Method("TRACE") } /** diff --git a/core/src/main/scala/com/softwaremill/sttp/package.scala b/core/src/main/scala/com/softwaremill/sttp/package.scala index 67be14a..40b8d82 100644 --- a/core/src/main/scala/com/softwaremill/sttp/package.scala +++ b/core/src/main/scala/com/softwaremill/sttp/package.scala @@ -61,6 +61,10 @@ package object sttp { type Empty[X] = None.type def ignoreResponse: ResponseAs[Unit] = IgnoreResponse + /** + * Uses `utf-8` encoding. + */ + def responseAsString: ResponseAs[String] = responseAsString(Utf8) def responseAsString(encoding: String): ResponseAs[String] = ResponseAsString(encoding) def responseAsByteArray: ResponseAs[Array[Byte]] = ResponseAsByteArray def responseAsStream[S]: ResponseAsStream[S] = ResponseAsStream[S]() @@ -137,41 +141,41 @@ package object sttp { } /** - * If content type is not specified, will be set to `text/plain` with `utf-8` encoding. + * If content type is not yet specified, will be set to `text/plain` with `utf-8` encoding. */ def data(b: String): RequestTemplate[U] = data(b, Utf8) /** - * If content type is not specified, will be set to `text/plain` with the given encoding. + * If content type is not yet specified, will be set to `text/plain` with the given encoding. */ def data(b: String, encoding: String): RequestTemplate[U] = setContentTypeIfMissing(contentTypeWithEncoding(TextPlainContentType, encoding)).copy(body = StringBody(b, encoding)) /** - * If content type is not specified, will be set to `application/octet-stream`. + * If content type is not yet specified, will be set to `application/octet-stream`. */ def data(b: Array[Byte]): RequestTemplate[U] = setContentTypeIfMissing(ApplicationOctetStreamContentType).copy(body = ByteArrayBody(b)) /** - * If content type is not specified, will be set to `application/octet-stream`. + * If content type is not yet specified, will be set to `application/octet-stream`. */ def data(b: ByteBuffer): RequestTemplate[U] = setContentTypeIfMissing(ApplicationOctetStreamContentType).copy(body = ByteBufferBody(b)) /** - * If content type is not specified, will be set to `application/octet-stream`. + * If content type is not yet specified, will be set to `application/octet-stream`. */ def data(b: InputStream): RequestTemplate[U] = setContentTypeIfMissing(ApplicationOctetStreamContentType).copy(body = InputStreamBody(b)) /** - * If content type is not specified, will be set to `application/octet-stream`. + * If content type is not yet specified, will be set to `application/octet-stream`. */ def data(b: File): RequestTemplate[U] = setContentTypeIfMissing(ApplicationOctetStreamContentType).copy(body = FileBody(b)) /** - * If content type is not specified, will be set to `application/octet-stream`. + * If content type is not yet specified, will be set to `application/octet-stream`. */ def data(b: Path): RequestTemplate[U] = setContentTypeIfMissing(ApplicationOctetStreamContentType).copy(body = PathBody(b)) /** - * If content type is not specified, will be set to `application/octet-stream`. + * If content type is not yet specified, will be set to `application/octet-stream`. */ def data[T: BodySerializer](b: T): RequestTemplate[U] = setContentTypeIfMissing(ApplicationOctetStreamContentType).copy(body = SerializableBody(implicitly[BodySerializer[T]], b)) -- cgit v1.2.3