Reputation: 1997
I want to "submit a form" through spray like this:
POST / HTTP/1.1
Host: hoge.org
Content-Type: application/x-www-form-urlencoded
username=myid&password=mypw
I know how to define POST
, Host
and Content-Type
.
The thing is how to put the contents (username=...
) in the request.
Here is my code waiting for the insertion of the contents:
//↑boiler plate↑
val pipe = (
addHeader(Host("hoge.org"))
~> addHeader(`Content-Type`(`application/x-www-form-urlencoded`))
~> sendReceive.apply
)
pipe(Post("/")) onComplete {
case Success(res) => println("okpk")
case Failure(exc) => println(exc)
}
Thank you!
Upvotes: 1
Views: 1262