From: "Iñaki Baz Castillo" <ibc@aliax.net>
To: rack-devel@googlegroups.com
Subject: Re: CommonLogger (and Clogger) generates strange symbols in the response body
Date: Fri, 4 Sep 2009 01:28:05 +0200 [thread overview]
Message-ID: <200909040128.05580.ibc@aliax.net> (raw)
In-Reply-To: <200909040102.14378.ibc@aliax.net>
El Viernes, 4 de Septiembre de 2009, Iñaki Baz Castillo escribió:
> Hi, I can't understand why the following issue occurs in the response body
> when using CommonLogger:
>
>
> ----- app_logic.rb -----
> class AppLogic
> def call(env)
> 200, {"Content-Type" => "text/plain"}, "line1\nline2\nline3\n"
> end
> end
> ------------------------
>
>
> ------- run_server.rb ------
> require "app_logic.rb"
> rack_inner_app = AppLogic.new
>
> rack_app = Rack::Builder.new {
> use Rack::CommonLogger, $stderr
> run rack_inner_app
> }.to_app
>
> Rack::Handler::Thin.run rack_app
> ----------------------------
>
>
>
> The reply I get in the 200 OK response is as follows:
>
> -------------
> HTTP/1.1 200 OK
> Transfer-Encoding: chunked
> Content-Type: text/plain
> Server: OpenXDMS
> Connection: close
>
> 6
> line1
>
> 6
> line2
>
> 6
> line3
>
> 0
>
> -------------
>
> As you can see, the number above each real body line is the length of the
> line below it (in hexadecimal when > 10).
>
>
> If I comment the CommonLogger line, then I get the correct body:
>
> --------------
> line1
> line2
> line3
> --------------
>
>
>
> It occurs the same if I log to a file and also if I use Clogger instead of
> CommonLogger.
>
> Is there something wrong in my code? is it the expected behaviour? (I
> cannot figure it of course as it breaks the response).
It's not an error in my code as a simpler example also issues this problem:
-----simple_rack.rb--------
require 'rubygems'
require 'rack'
infinity = Proc.new {|env| [200, {"Content-Type" => "text/html"}, "hello"]}
builder = Rack::Builder.new do
use Rack::CommonLogger
run infinity
end
Rack::Handler::Mongrel.run builder, :Port => 9292
---------------------------
~# ruby1.8 simple_rack.rb
And this is the response:
---------------------------
HTTP/1.1 200 OK
Connection: close
Date: Thu, 03 Sep 2009 23:24:39 GMT
Transfer-Encoding: chunked
Content-Type: text/html
4
hello
0
---------------------------
Without the CommonLogger middleware, the response body is correct:
----------
hello
----------
¿?¿?
--
Iñaki Baz Castillo <ibc@aliax.net>
next prev parent reply other threads:[~2009-09-03 23:28 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-09-03 23:02 CommonLogger (and Clogger) generates strange symbols in the response body Iñaki Baz Castillo
2009-09-03 23:28 ` Iñaki Baz Castillo [this message]
2009-09-04 1:35 ` Eric Wong
2009-09-04 13:47 ` Iñaki Baz Castillo
2009-09-04 19:13 ` Eric Wong
2009-09-04 19:20 ` Iñaki Baz Castillo
2009-09-04 19:42 ` Eric Wong
2009-09-04 19:44 ` Iñaki Baz Castillo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://groups.google.com/group/rack-devel
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200909040128.05580.ibc@aliax.net \
--to=rack-devel@googlegroups.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).