Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test support for HEAD methods. [#20]
HEAD support has existed in main for a long time, but previous versions of Jetty choked while testing it. 7.4.x handles it just fine, so the methods have been added ot the test DSL. Add support for the other methods before we close #51.
- Loading branch information
1 parent
8fbf725
commit f25bc33
Showing
3 changed files
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package org.scalatra | ||
|
||
import org.scalatra.specs2.ScalatraSpec | ||
|
||
class HeadSpec extends ScalatraSpec { def is = | ||
"A HEAD request should" ^ | ||
"return no body" ! noBody^ | ||
"preserve headers" ! preserveHeaders^ | ||
end | ||
|
||
val servletHolder = addServlet(classOf[HeadSpecServlet], "/*") | ||
|
||
def noBody = head("/") { response.body must_== "" } | ||
|
||
def preserveHeaders = head("/") { | ||
header("X-Powered-By") must_== "caffeine" | ||
} | ||
} | ||
|
||
class HeadSpecServlet extends ScalatraServlet { | ||
get("/") { | ||
response.addHeader("X-Powered-By", "caffeine") | ||
"poof -- watch me disappear" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters