diff options
Diffstat (limited to 'core/src/main/scala/com/softwaremill/sttp/HttpURLConnectionSttpHandler.scala')
-rw-r--r-- | core/src/main/scala/com/softwaremill/sttp/HttpURLConnectionSttpHandler.scala | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/core/src/main/scala/com/softwaremill/sttp/HttpURLConnectionSttpHandler.scala b/core/src/main/scala/com/softwaremill/sttp/HttpURLConnectionSttpHandler.scala index 7fd7220..a42e26d 100644 --- a/core/src/main/scala/com/softwaremill/sttp/HttpURLConnectionSttpHandler.scala +++ b/core/src/main/scala/com/softwaremill/sttp/HttpURLConnectionSttpHandler.scala @@ -12,8 +12,7 @@ import scala.io.Source import scala.collection.JavaConverters._ object HttpURLConnectionSttpHandler extends SttpHandler[Id, Nothing] { - override def send[T](r: Request, - responseAs: ResponseAs[T, Nothing]): Response[T] = { + override def send[T](r: Request[T, Nothing]): Response[T] = { val c = r.uri.toURL.openConnection().asInstanceOf[HttpURLConnection] c.setRequestMethod(r.method.m) r.headers.foreach { case (k, v) => c.setRequestProperty(k, v) } @@ -22,14 +21,14 @@ object HttpURLConnectionSttpHandler extends SttpHandler[Id, Nothing] { try { val is = c.getInputStream - readResponse(c, is, responseAs) + readResponse(c, is, r.responseAs) } catch { case _: IOException if c.getResponseCode != -1 => - readResponse(c, c.getErrorStream, responseAs) + readResponse(c, c.getErrorStream, r.responseAs) } } - private def setBody(body: RequestBody, c: HttpURLConnection): Unit = { + private def setBody(body: RequestBody[Nothing], c: HttpURLConnection): Unit = { if (body != NoBody) c.setDoOutput(true) def copyStream(in: InputStream, out: OutputStream): Unit = { @@ -71,6 +70,10 @@ object HttpURLConnectionSttpHandler extends SttpHandler[Id, Nothing] { case SerializableBody(f, t) => setBody(f(t), c) + + case StreamBody(s) => + // we have an instance of nothing - everything's possible! + assert(2 + 2 == 5) } } |