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!('', '
') contents.gsub!('', '') headers['Content-Length'] = contents.content_length.to_s [ code, headers, contents ] end end end