#3 new
hnguyen (at co.brazos.tx)

prawnto with jruby && env[SERVER_PROTOCOL] == nil

Reported by hnguyen (at co.brazos.tx) | March 31st, 2009 @ 02:36 PM

I was testing on loading a prawn page under jruby and i get this error

ActionView::TemplateError (undefined method downcase' for nil:NilClass) on line [#1](/projects/23449/tickets/1 "Ticket #1") of app/views/questions/download_pdf.pdf.prawn: 1: pdf.font "#{Prawn::BASEDIR}/data/fonts/comicsans.ttf" 2: pdf.text "hello" 3: pdf.text "hello"

vendor/plugins/prawnto/lib/prawnto/template_handler/compile_support.rb:34:in `ssl_request?'
vendor/plugins/prawnto/lib/prawnto/template_handler/compile_support.rb:40:in `set_pragma'
vendor/plugins/prawnto/lib/prawnto/template_handler/compile_support.rb:20:in `set_headers'
vendor/plugins/prawnto/lib/prawnto/template_handler/compile_support.rb:12:in `initialize'
vendor/plugins/prawnto/lib/prawnto/action_view.rb:6:in `_prawnto_compile_setup'
gems/gems/actionpack-2.2.2/lib/action_view/renderable.rb:39:in `render'
gems/gems/actionpack-2.2.2/lib/action_view/template.rb:73:in `render_template'
gems/gems/actionpack-2.2.2/lib/action_view/base.rb:256:in `render'

so in vendor/plugins/prawnto/lib/prawnto/template_handler/compile_support.rb file i commented out set_pragma and set_cache_control under the set_header method and voila it works. the error is coming from ssl_request?. it cannot get the environment variable. o and i was using ssl on a j2ee server

Comments and changes to this ticket

  • hnguyen (at co.brazos.tx)

    hnguyen (at co.brazos.tx) April 1st, 2009 @ 11:39 AM

    just letting you know i changed the ssl_request? method to this so that i can still have it working without me commenting out the code.

    def ssl_request? if defined?(JRUBY_VERSION)



    @controller.request.env['SERVER_PROTOCOL'].downcase == "https"

    end end memoize :ssl_request?

    it checks if it is running on jruby and if it does then glassfish would set the javax.servlet.request.cipher_suite env variable to any ssl cipher if using ssl, else it would not exist. im not sure if other j2ee servers do it differently.

  • Bassel Samman

    Bassel Samman October 1st, 2009 @ 10:54 AM

    I noticed that rack.url_scheme is set to https instead, so here is what worked for me:

    def ssl_request?
      is_ssl_protocol_var_set = @controller.request.env['SERVER_PROTOCOL'] || @controller.request.env['rack.url_scheme']
      is_ssl_protocol_var_set and is_ssl_protocol_var_set == "https"
  • Bassel Samman

    Bassel Samman October 1st, 2009 @ 11:06 AM


    def ssl_request?
      ssl_protocol_var_set = @controller.request.env['SERVER_PROTOCOL'] || @controller.request.env['rack.url_scheme']
      ssl_protocol_var_set and ssl_protocol_var_set.downcase == "https"

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »