Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
bug of finch-0.9.2 (this is fixed by #485)
scalaVersion := "2.11.7"
libraryDependencies += "com.github.finagle" %% "finch-core" % "0.9.2"
package finch.bug
import io.finch._
import com.twitter.io.Buf
import com.twitter.finagle.http._
import com.twitter.util.{ Await, Duration }
object Main extends App {
val string = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
val e: Endpoint[String] = post(* ? body) { b: String =>
// `body` RequestReader written as the below code (finch-0.9.2):
//
// ```
// val buffer = ChannelBufferBuf.Owned.extract(req.content)
// Some(new String(buffer.array(), "UTF-8"))
// ```
println(b.getBytes.toSeq) // filled by \0
Ok((b == string).toString) //=> false
}
val service = e.toService
val req = RequestBuilder()
.url("http://localhost")
.buildPost(Buf.Utf8(string))
val res = Await.result(service(req), Duration.fromSeconds(10))
println(res.contentString) //=> false
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment