src/Pure/General/http.scala
changeset 80202 03c058592c58
parent 80201 6ac48d53d371
child 80243 b2889dd54a2a
equal deleted inserted replaced
80201:6ac48d53d371 80202:03c058592c58
   220   class Response private[HTTP](val output: Bytes, val content_type: String) {
   220   class Response private[HTTP](val output: Bytes, val content_type: String) {
   221     override def toString: String = output.toString
   221     override def toString: String = output.toString
   222 
   222 
   223     def write(http: HttpExchange, code: Int, is_head: Boolean = false): Unit = {
   223     def write(http: HttpExchange, code: Int, is_head: Boolean = false): Unit = {
   224       http.getResponseHeaders.set("Content-Type", content_type)
   224       http.getResponseHeaders.set("Content-Type", content_type)
       
   225       http.getResponseHeaders.set("Content-Length", output.length.toString)
   225       http.sendResponseHeaders(code, if (is_head) -1 else output.length.toLong)
   226       http.sendResponseHeaders(code, if (is_head) -1 else output.length.toLong)
   226       if (!is_head) using(http.getResponseBody)(output.write_stream)
   227       if (!is_head) using(http.getResponseBody)(output.write_stream)
   227     }
   228     }
   228   }
   229   }
   229 
   230