@@ -9,9 +9,10 @@ import org.scalaexercises.evaluator.http.HttpClient._
9
9
10
10
import scala .concurrent .Future
11
11
12
- import fr .hmil .roshttp .body .Implicits ._
13
12
import fr .hmil .roshttp .{HttpRequest , Method , HttpResponse }
14
- import fr .hmil .roshttp .body .JSONBody
13
+ import fr .hmil .roshttp .body .BodyPart
14
+
15
+ import java .nio .ByteBuffer
15
16
16
17
case class HttpRequestBuilder (
17
18
url : String ,
@@ -20,6 +21,12 @@ case class HttpRequestBuilder(
20
21
body : String = " "
21
22
) {
22
23
24
+ case class CirceJSONBody (value : String ) extends BodyPart {
25
+ override def contentType : String = s " application/json; charset=utf-8 "
26
+
27
+ override def content : ByteBuffer = ByteBuffer .wrap(value.getBytes(" utf-8" ))
28
+ }
29
+
23
30
def withHeaders (headers : Headers ) = copy(headers = headers)
24
31
25
32
def withBody (body : String ) = copy(body = body)
@@ -28,9 +35,9 @@ case class HttpRequestBuilder(
28
35
29
36
val request = HttpRequest (url)
30
37
.withMethod(Method (httpVerb))
38
+ .withHeader(" content-type" , " application/json" )
31
39
.withHeaders(headers.toList: _* )
32
- .withHeader(" content.type" , " application/json" )
33
40
34
- request.post( JSONBody (body))
41
+ request.send( CirceJSONBody (body))
35
42
}
36
43
}
0 commit comments