Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

support reading params in content body for HTTP methods other than POST #239

Closed
wants to merge 1 commit into from

2 participants

Jeffrey Olchovy Moses Nakamura
Moses Nakamura
Collaborator

This has been merged internally. We'll close this when it's publicly available. Thanks for the PR!

Moses Nakamura
Collaborator

This was merged. Thanks again for your contribution!

Moses Nakamura mosesn closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
2  finagle-http/src/main/scala/com/twitter/finagle/http/ParamMap.scala
View
@@ -170,7 +170,7 @@ class RequestParamMap(val request: Request) extends ParamMap {
parseParams(request.uri)
private[this] val postParams: JMap[String, JList[String]] = {
- if ((request.method == Method.Post || request.method == Method.Put) &&
+ if (request.method != Method.Trace &&
request.mediaType == Some(MediaType.WwwForm) &&
request.length > 0) {
parseParams("?" + request.contentString)
22 finagle-http/src/test/scala/com/twitter/finagle/http/ParamMapSpec.scala
View
@@ -167,12 +167,22 @@ class ParamMapSpec extends SpecificationWithJUnit {
}
}
- "ignore body when not a POST" in {
- val request = Request("/search.json?lang=en")
- request.contentType = "application/x-www-form-urlencoded"
- request.contentString = "q=twitter"
- request.params.get("q") must_== None
- request.params.get("lang") must_== Some("en")
+ "ignore body only during TRACE requests" in {
+ val url = "/search.json?lang=en"
+ val contentType = "application/x-www-form-urlencoded"
+ val contentString = "q=twitter"
+
+ val getRequest = Request(Method.Get, url)
+ getRequest.contentType = contentType
+ getRequest.contentString = contentString
+ getRequest.params.get("q") must_== Some("twitter")
+ getRequest.params.get("lang") must_== Some("en")
+
+ val traceRequest = Request(Method.Trace, url)
+ traceRequest.contentType = contentType
+ traceRequest.contentString = contentString
+ traceRequest.params.get("q") must_== None
+ traceRequest.params.get("lang") must_== Some("en")
}
"weird encoded characters" in {
Something went wrong with that request. Please try again.