nitcorn: use `bytelen` instead of `length` when setting `Content-Length` header
authorAlexandre Terrasa <alexandre@moz-code.org>
Mon, 3 Aug 2015 21:17:32 +0000 (17:17 -0400)
committerAlexandre Terrasa <alexandre@moz-code.org>
Mon, 3 Aug 2015 21:17:32 +0000 (17:17 -0400)
So UTF-8 files are rendered correctly.

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

lib/libevent.nit
lib/nitcorn/http_response.nit

index 1ce2762..7794ed5 100644 (file)
@@ -157,7 +157,7 @@ class Connection
        # Write a string to the connection
        redef fun write(str)
        do
-               native_buffer_event.write(str.to_cstring, str.length)
+               native_buffer_event.write(str.to_cstring, str.bytelen)
        end
 
        redef fun write_byte(byte) do native_buffer_event.write_byte(byte)
index ef87adb..523c051 100644 (file)
@@ -42,7 +42,7 @@ class HttpResponse
        do
                # Set the content length if not already set
                if not header.keys.has("Content-Length") then
-                       header["Content-Length"] = body.length.to_s
+                       header["Content-Length"] = body.bytelen.to_s
                end
 
                # Set server ID