Skip to content

Instantly share code, notes, and snippets.

@amutake
Created December 19, 2015 22:14
Show Gist options
  • Save amutake/20137e120afab8f9f0ef to your computer and use it in GitHub Desktop.
Save amutake/20137e120afab8f9f0ef to your computer and use it in GitHub Desktop.
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