Permalink
Browse files

send dispatch user-agent with build-info version

  • Loading branch information...
1 parent 71de1fe commit bcf6d255317088ca1e32c6e6ecd4dce1979ac718 @softprops softprops committed Dec 22, 2012
Showing with 22 additions and 1 deletion.
  1. +8 −0 core/build.sbt
  2. +1 −0 core/src/main/scala/execution.scala
  3. +10 −0 core/src/test/scala/basic.scala
  4. +3 −1 project/plugins.sbt
View
@@ -8,3 +8,11 @@ libraryDependencies ++= Seq(
)
seq(lsSettings :_*)
+
+seq(buildInfoSettings:_*)
+
+sourceGenerators in Compile <+= buildInfo
+
+buildInfoKeys := Seq[BuildInfoKey](version)
+
+buildInfoPackage := "dispatch"
@@ -48,6 +48,7 @@ private [dispatch] object Defaults {
lazy val client = new AsyncHttpClient(config)
lazy val timeout = Duration.None
lazy val config = new AsyncHttpClientConfig.Builder()
+ .setUserAgent("Dispatch/%s" format BuildInfo.version)
.setAsyncHttpClientProviderConfig(
new NettyAsyncHttpProviderConfig().addProperty(
NettyAsyncHttpProviderConfig.BOSS_EXECUTOR_SERVICE, bossExecutor
@@ -20,6 +20,8 @@ with DispatchCleanup {
PlainTextContent ~> ResponseString(req.method + URLDecoder.decode(echo, "utf-8"))
case req @ Path(Seg("echopath" :: Nil)) =>
PlainTextContent ~> ResponseString(req.method)
+ case Path(Seg("agent" :: Nil)) & UserAgent(agent) =>
+ PlainTextContent ~> ResponseString(agent)
}).start()
}
@@ -71,4 +73,12 @@ with DispatchCleanup {
)
res() =? ("OPTIONS" + sample)
}
+
+ property("Send Dispatch/%s User-Agent" format BuildInfo.version) = forAll(Gen.alphaStr) { (sample: String) =>
+ val res = Http(
+ localhost / "agent" > as.String
+ )
+ res() =? ("Dispatch/%s" format BuildInfo.version)
+ }
+
}
View
@@ -2,9 +2,11 @@ addSbtPlugin("me.lessis" % "ls-sbt" % "0.1.2")
addSbtPlugin("com.jsuereth" % "xsbt-gpg-plugin" % "0.6")
+addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.2.0")
+
resolvers ++= Seq(
"less is" at "http://repo.lessis.me",
"coda" at "http://repo.codahale.com"
)
-resolvers += Resolver.url("sbt-plugin-releases", new URL("http://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-releases/"))(Resolver.ivyStylePatterns)
+resolvers += Resolver.url("sbt-plugin-releases", new URL("http://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-releases/"))(Resolver.ivyStylePatterns)

0 comments on commit bcf6d25

Please sign in to comment.