rack-devel archive mirror (unofficial) https://groups.google.com/group/rack-devel
 help / color / mirror / Atom feed
From: "Iñaki Baz Castillo" <ibc@aliax.net>
To: rack-devel@googlegroups.com
Subject: Re: Potential Rack-Contrib contributions
Date: Sat, 16 Jan 2010 14:22:28 +0100	[thread overview]
Message-ID: <201001161422.28489.ibc@aliax.net> (raw)
In-Reply-To: <dad5ac82-658e-472d-a37a-8af4bead2e79@26g2000yqo.googlegroups.com>

El Viernes, 15 de Enero de 2010, Geoff Buesing escribió:
> * Rackables::DefaultCharset - Sets charset directive in Content-Type
> header

Hi, I'm inspecting DefaultCharset middleware:


  class DefaultCharset
    HAS_CHARSET = /charset=/
 
    def initialize(app, value = 'utf-8')
      @app = app
      @value = value
    end
 
    def call(env)
      response = @app.call(env)
      headers = response[1]
      content_type = headers['Content-Type']
      if content_type && content_type !~ HAS_CHARSET
        headers['Content-Type'] = "#{content_type}; charset=#{@value}"
      end
      response
    end
  end


I see two issues here:

1) HAS_CHARSET = /charset=/
Note that HTTP grammar is case insensitive (in most of the cases) so IMGO it 
shoud be:

  HAS_CHARSET = /charset=/i

2) content_type = headers['Content-Type']
Perhaps I'm wrong, but what about if the response headers created by other 
middleware or Rack app uses "content-type" or "CONTENT-type"? again RFC 2616 
BNF grammar is case insensitive by default.

However in case 2 perhaps I'm wrong as I don't know if Rack require some exact 
format for headers name into generated responses.


Regards.



-- 
Iñaki Baz Castillo <ibc@aliax.net>

  parent reply	other threads:[~2010-01-16 13:22 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-15 16:23 Potential Rack-Contrib contributions Geoff Buesing
2010-01-16 12:29 ` Ryan Tomayko
2010-01-16 13:22 ` Iñaki Baz Castillo [this message]
2010-01-16 13:38   ` Iñaki Baz Castillo
2010-01-16 14:01     ` Michael Fellinger
2010-01-16 14:47       ` Iñaki Baz Castillo
2010-01-16 17:47         ` Geoff Buesing
2010-01-17 18:32           ` Geoff Buesing
2010-01-17 19:15             ` Geoff Buesing

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=201001161422.28489.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).