equal
deleted
inserted
replaced
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 |