module Rack # Rack::Facebook formats HTTP responses to remove certain status codes # and HTML entities that are invalid as FBML responses. class Facebook def initialize(app) @app = app end def call(env) code, headers, body = @app.call(env) if code >= 500 && code < 600 code = 200 end contents = '' body.each {|p| contents += p } contents.gsub!(/txmt:\/\//, 'http://textmate.local/') contents.gsub!('','
') contents.gsub!('','
') headers['Content-Length'] = contents.length.to_s [ code, headers, contents ] end end end