aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authoradamw <adam@warski.org>2017-06-30 17:14:54 +0200
committeradamw <adam@warski.org>2017-06-30 17:14:54 +0200
commit10edc9d4469bac8fa760befb91422cad96d838fe (patch)
treea1cf4ecbf6771d455d5af38473fc38c43c7c67b5 /core
parente0e1c4be8642c2bf3fb70ef6427565c6fcf4d3ef (diff)
downloadsttp-10edc9d4469bac8fa760befb91422cad96d838fe.tar.gz
sttp-10edc9d4469bac8fa760befb91422cad96d838fe.tar.bz2
sttp-10edc9d4469bac8fa760befb91422cad96d838fe.zip
More methods
Diffstat (limited to 'core')
-rw-r--r--core/src/main/scala/com/softwaremill/sttp/model/package.scala2
-rw-r--r--core/src/main/scala/com/softwaremill/sttp/package.scala20
2 files changed, 14 insertions, 8 deletions
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))