Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Padrino returns "text/html" Content-Type always when using cache #1462

Closed
tune opened this issue Oct 17, 2013 · 2 comments
Closed

Padrino returns "text/html" Content-Type always when using cache #1462

tune opened this issue Oct 17, 2013 · 2 comments

Comments

@tune
Copy link

tune commented Oct 17, 2013

As mentioned in issue #745, current padrino returns "text/html" content-type regardless of the controller directive.

I've tried to reproduce this problem as following.


Confirm Ruby & Padrino Version

$ ruby -v
ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-linux]

$ padrino -v
Padrino v. 0.11.4

Create Project & Setup Sample App

$ padrino g project sample
      create  
      create  .gitignore
      create  config.ru
      create  config/apps.rb
      ...

$ cd sample
$ bundle install --path=vendor/bundle 
Fetching gem metadata from https://rubygems.org/.........
Fetching gem metadata from https://rubygems.org/..
Installing rake (10.1.0) 
Installing i18n (0.6.5) 
Installing multi_json (1.8.2) 
Installing activesupport (3.2.14) 
...

$ bundle exec padrino g controller index get:index
      create  app/controllers/index.rb
      create  app/helpers/index_helper.rb
      create  app/views/index

$ vi app/controllers/index.rb

require 'json'
Sample::App.controllers :index do
  get :index, :provides=>:json do
    JSON.pretty_generate($LOAD_PATH)
  end
end

Confirm JSON Output

Output of http://localhost:3000/index

[
  "/home/tune/sample/vendor/bundle/ruby/2.0.0/gems/slim-2.0.1/lib",
  "/home/tune/sample/vendor/bundle/ruby/2.0.0/gems/temple-0.6.7/lib",
  "/home/tune/sample/vendor/bundle/ruby/2.0.0/gems/padrino-0.11.4/lib",
   ...
  "/home/tune/sample/lib",
  "/home/tune/sample/models",
  "/home/tune/sample/shared",
  "/home/tune/sample/app/models",
  "/home/tune/sample/app/lib",
  "/home/tune/sample/app/mailers",
  "/home/tune/sample/app/controllers",
  "/home/tune/sample/app/helpers"
]

HTTP Response Header from Padrino

HTTP/1.1 200 OK
Content-Type: application/json;charset=utf-8
Content-Length: 3546
X-Content-Type-Options: nosniff
Server: WEBrick/1.3.1 (Ruby/2.0.0/2013-06-27)
Date: Thu, 17 Oct 2013 02:38:24 GMT

Enable Cache

$ vi app/app.rb

module Sample
  class App < Padrino::Application
    ###
    # Caching support.
    #
    register Padrino::Cache
    enable :caching           
  end
end

$ vi app/controllers/index.rb

require 'json'
Sample::App.controllers :index do
  get :index, :provides=>:json, :cache=>true do
    JSON.pretty_generate($LOAD_PATH)
  end
end

Padrino log message & HTTP Response Header from Padrino for 1st access

exec bundle exec padrino start and access "http://localhost:3000/index".

  DEBUG -  SET CACHE (0.0005s) /index
  DEBUG -        GET (0.0432s) /index - 200 OK
HTTP/1.1 200 OK
Content-Type: application/json;charset=utf-8
Content-Length: 3546
X-Content-Type-Options: nosniff
Server: WEBrick/1.3.1 (Ruby/2.0.0/2013-06-27)
Date: Thu, 17 Oct 2013 02:42:14 GMT
Connection: Keep-Alive

Padrino log message & HTTP Response Header from Padrino for 2nd access

  DEBUG -  GET CACHE (0.0003s) /index
  DEBUG -        GET (0.0016s) /index - 200 OK
HTTP/1.1 200 OK
Content-Type: text/html;charset=utf-8
Content-Length: 3546
X-Xss-Protection: 1; mode=block
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
Server: WEBrick/1.3.1 (Ruby/2.0.0/2013-06-27)
Date: Thu, 17 Oct 2013 02:42:20 GMT
Connection: Keep-Alive

Use Padrino Edge

$ vi Gemfile

# Use ":git" directive because my PC is behind proxy that does not allow git protocol.

# Padrino Stable Gem
#gem 'padrino', '0.11.4'

# Or Padrino Edge
#gem 'padrino', :github => 'padrino/padrino-framework'
gem 'padrino', :git => 'http://github.com/padrino/padrino-framework' 

$ bundle update
$ bundle exec padrino start

-> Completely same result as v0.11.4

@ujifgc ujifgc closed this as completed in 2005508 Oct 17, 2013
@ujifgc
Copy link
Member

ujifgc commented Oct 17, 2013

This functionality was untested and was removed by massive sloppy merge. Thank you for bringing this to attention.

@nesquena
Copy link
Member

I'm more concerned we had no unit testing for these that caught the issue but thanks for fixing it 


Nathan Esquenazi
CodePath Co-founder
http://thecodepath.com

On Wed, Oct 16, 2013 at 11:58 PM, Igor Bochkariov
notifications@github.com wrote:

This functionality was untested and was removed by massive sloppy merge. Thank you for bringing this to attention.

Reply to this email directly or view it on GitHub:
#1462 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants