Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,12 @@ trait ToBoxTheResponse {
(baseUrl + fullUrl, httpClient.executeMethod(getter)) match {
case (server, responseCode) =>
val respHeaders = slurpApacheHeaders(getter.getResponseHeaders)
val body = for {
st <- Box !! getter.getResponseBodyAsStream
bytes <- tryo(readWholeStream(st))
} yield bytes

Full(new TheResponse(baseUrl,
responseCode, getter.getStatusText,
respHeaders,
for {st <- Box !! getter.getResponseBodyAsStream
bytes <- tryo(readWholeStream(st))
} yield bytes,
httpClient))
Full(new TheResponse(baseUrl, responseCode, getter.getStatusText, respHeaders, body, httpClient))
}
} catch {
case e: IOException => Failure(baseUrl + fullUrl, Full(e), Empty)
Expand Down Expand Up @@ -793,9 +791,7 @@ class HttpResponse(baseUrl: String,
code: Int, msg: String,
headers: Map[String, List[String]],
body: Box[Array[Byte]],
theHttpClient: HttpClient) extends
BaseResponse(baseUrl, code, msg, headers, body, theHttpClient) with
ToResponse with TestResponse {
theHttpClient: HttpClient) extends BaseResponse(baseUrl, code, msg, headers, body, theHttpClient) with ToResponse with TestResponse {
}

/**
Expand All @@ -806,9 +802,7 @@ class TheResponse(baseUrl: String,
code: Int, msg: String,
headers: Map[String, List[String]],
body: Box[Array[Byte]],
theHttpClient: HttpClient) extends
BaseResponse(baseUrl, code, msg, headers, body, theHttpClient) with
ToBoxTheResponse {
theHttpClient: HttpClient) extends BaseResponse(baseUrl, code, msg, headers, body, theHttpClient) with ToBoxTheResponse {
type SelfType = TheResponse

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import org.specs2.mutable.Specification

import org.json4s.JsonDSL._


/**
* System under specification for MockHttpRequest.
*/
Expand Down Expand Up @@ -95,7 +94,7 @@ class MockHttpRequestSpec extends Specification {
"properly set a default content type for JSON" in {
val testRequest = new MockHttpServletRequest(TEST_URL, "/test")

testRequest.body = ("name" -> "joe")
testRequest.body_=("name" -> "joe")

testRequest.contentType must_== "application/json"
}
Expand All @@ -111,7 +110,7 @@ class MockHttpRequestSpec extends Specification {
"properly set a default content type for XML" in {
val testRequest = new MockHttpServletRequest(TEST_URL, "/test")

testRequest.body = <test/>
testRequest.body_=(<test/>)

testRequest.contentType must_== "text/xml"
}
Expand All @@ -127,7 +126,7 @@ class MockHttpRequestSpec extends Specification {
"properly set a default content type for a String" in {
val testRequest = new MockHttpServletRequest(TEST_URL, "/test")

testRequest.body = "test"
testRequest.body_=("test")

testRequest.contentType must_== "text/plain"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,8 @@ object MyCode extends TestKit {
val baseUrl = ""

val l2: TestResponse = post("/foo")
l2.foreach {
x: HttpResponse =>
val l3: TestResponse = x.get("ddd")
println("Hello")
l2.foreach { (x: HttpResponse) =>
val l3: TestResponse = x.get("ddd")
}


Expand All @@ -50,10 +48,8 @@ object MyBoxCode extends RequestKit {
def baseUrl = ""

val l2: Box[TheResponse] = post("/foo")
l2.foreach {
x: TheResponse =>
val l3: Box[TheResponse] = x.get("ddd")
println("Hello")
l2.foreach { (x: TheResponse) =>
val l3: Box[TheResponse] = x.get("ddd")
}


Expand Down