aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoradamw <adam@warski.org>2017-07-08 20:14:09 +0200
committeradamw <adam@warski.org>2017-07-08 20:14:09 +0200
commit9ab159cabc290dbc271e9716249ab9eb67ed5879 (patch)
treeb78934634e4b1f6215e7676addcc56248b7679ea
parentbc942a647d918c2c725115424be202eb040dd3ca (diff)
downloadsttp-9ab159cabc290dbc271e9716249ab9eb67ed5879.tar.gz
sttp-9ab159cabc290dbc271e9716249ab9eb67ed5879.tar.bz2
sttp-9ab159cabc290dbc271e9716249ab9eb67ed5879.zip
data -> body
-rw-r--r--core/src/main/scala/com/softwaremill/sttp/package.scala16
-rw-r--r--tests/src/test/scala/com/softwaremill/sttp/BasicTests.scala16
2 files changed, 16 insertions, 16 deletions
diff --git a/core/src/main/scala/com/softwaremill/sttp/package.scala b/core/src/main/scala/com/softwaremill/sttp/package.scala
index 1122f2e..52d06f0 100644
--- a/core/src/main/scala/com/softwaremill/sttp/package.scala
+++ b/core/src/main/scala/com/softwaremill/sttp/package.scala
@@ -98,41 +98,41 @@ package object sttp {
/**
* 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)
+ def body(b: String): RequestTemplate[U] = body(b, Utf8)
/**
* 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] =
+ def body(b: String, encoding: String): RequestTemplate[U] =
setContentTypeIfMissing(contentTypeWithEncoding(TextPlainContentType, encoding)).copy(body = StringBody(b, encoding))
/**
* If content type is not yet specified, will be set to `application/octet-stream`.
*/
- def data(b: Array[Byte]): RequestTemplate[U] =
+ def body(b: Array[Byte]): RequestTemplate[U] =
setContentTypeIfMissing(ApplicationOctetStreamContentType).copy(body = ByteArrayBody(b))
/**
* If content type is not yet specified, will be set to `application/octet-stream`.
*/
- def data(b: ByteBuffer): RequestTemplate[U] =
+ def body(b: ByteBuffer): RequestTemplate[U] =
setContentTypeIfMissing(ApplicationOctetStreamContentType).copy(body = ByteBufferBody(b))
/**
* If content type is not yet specified, will be set to `application/octet-stream`.
*/
- def data(b: InputStream): RequestTemplate[U] =
+ def body(b: InputStream): RequestTemplate[U] =
setContentTypeIfMissing(ApplicationOctetStreamContentType).copy(body = InputStreamBody(b))
/**
* If content type is not yet specified, will be set to `application/octet-stream`.
*/
- def data(b: File): RequestTemplate[U] =
+ def body(b: File): RequestTemplate[U] =
setContentTypeIfMissing(ApplicationOctetStreamContentType).copy(body = FileBody(b))
/**
* If content type is not yet specified, will be set to `application/octet-stream`.
*/
- def data(b: Path): RequestTemplate[U] =
+ def body(b: Path): RequestTemplate[U] =
setContentTypeIfMissing(ApplicationOctetStreamContentType).copy(body = PathBody(b))
/**
* If content type is not yet specified, will be set to `application/octet-stream`.
*/
- def data[T: BodySerializer](b: T): RequestTemplate[U] =
+ def body[T: BodySerializer](b: T): RequestTemplate[U] =
setContentTypeIfMissing(ApplicationOctetStreamContentType).copy(body = SerializableBody(implicitly[BodySerializer[T]], b))
private def hasContentType: Boolean = headers.exists(_._1.toLowerCase.contains(ContentTypeHeader))
diff --git a/tests/src/test/scala/com/softwaremill/sttp/BasicTests.scala b/tests/src/test/scala/com/softwaremill/sttp/BasicTests.scala
index cc2d2fc..597c042 100644
--- a/tests/src/test/scala/com/softwaremill/sttp/BasicTests.scala
+++ b/tests/src/test/scala/com/softwaremill/sttp/BasicTests.scala
@@ -75,13 +75,13 @@ class BasicTests extends FlatSpec with Matchers with BeforeAndAfterAll with Scal
def parseResponseTests(): Unit = {
name should "parse response as string" in {
- val response = postEcho.data(testBody).send(responseAsString)
+ val response = postEcho.body(testBody).send(responseAsString)
val fc = forceResponse.force(response).body
fc should be (expectedPostEchoResponse)
}
name should "parse response as a byte array" in {
- val response = postEcho.data(testBody).send(responseAsByteArray)
+ val response = postEcho.body(testBody).send(responseAsByteArray)
val fc = new String(forceResponse.force(response).body, "UTF-8")
fc should be (expectedPostEchoResponse)
}
@@ -100,25 +100,25 @@ class BasicTests extends FlatSpec with Matchers with BeforeAndAfterAll with Scal
def bodyTests(): Unit = {
name should "post a string" in {
- val response = postEcho.data(testBody).send(responseAsString)
+ val response = postEcho.body(testBody).send(responseAsString)
val fc = forceResponse.force(response).body
fc should be (expectedPostEchoResponse)
}
name should "post a byte array" in {
- val response = postEcho.data(testBodyBytes).send(responseAsString)
+ val response = postEcho.body(testBodyBytes).send(responseAsString)
val fc = forceResponse.force(response).body
fc should be (expectedPostEchoResponse)
}
name should "post an input stream" in {
- val response = postEcho.data(new ByteArrayInputStream(testBodyBytes)).send(responseAsString)
+ val response = postEcho.body(new ByteArrayInputStream(testBodyBytes)).send(responseAsString)
val fc = forceResponse.force(response).body
fc should be (expectedPostEchoResponse)
}
name should "post a byte buffer" in {
- val response = postEcho.data(ByteBuffer.wrap(testBodyBytes)).send(responseAsString)
+ val response = postEcho.body(ByteBuffer.wrap(testBodyBytes)).send(responseAsString)
val fc = forceResponse.force(response).body
fc should be (expectedPostEchoResponse)
}
@@ -126,7 +126,7 @@ class BasicTests extends FlatSpec with Matchers with BeforeAndAfterAll with Scal
name should "post a file" in {
val f = File.newTemporaryFile().write(testBody)
try {
- val response = postEcho.data(f.toJava).send(responseAsString)
+ val response = postEcho.body(f.toJava).send(responseAsString)
val fc = forceResponse.force(response).body
fc should be(expectedPostEchoResponse)
} finally f.delete()
@@ -135,7 +135,7 @@ class BasicTests extends FlatSpec with Matchers with BeforeAndAfterAll with Scal
name should "post a path" in {
val f = File.newTemporaryFile().write(testBody)
try {
- val response = postEcho.data(f.toJava.toPath).send(responseAsString)
+ val response = postEcho.body(f.toJava.toPath).send(responseAsString)
val fc = forceResponse.force(response).body
fc should be(expectedPostEchoResponse)
} finally f.delete()