Class: PageMountController::ProxyResponse

Inherits:
Object
  • Object
show all
Defined in:
app/controllers/page_mount_controller.rb

Constant Summary collapse

DEFAULT_CONTENT_DISPOSITION =
'inline'
FILE_CONTENT_TYPES =
%w(
  application/octet-stream
  application/javascript
  text/plain # js.map
  application/json
)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ ProxyResponse

Returns a new instance of ProxyResponse.



116
117
118
# File 'app/controllers/page_mount_controller.rb', line 116

def initialize(response)
  @response = response
end

Instance Attribute Details

#responseObject (readonly)

Returns the value of attribute response.



114
115
116
# File 'app/controllers/page_mount_controller.rb', line 114

def response
  @response
end

Instance Method Details

#content_dispositionObject



135
136
137
# File 'app/controllers/page_mount_controller.rb', line 135

def content_disposition
  headers[:content_disposition] || DEFAULT_CONTENT_DISPOSITION
end

#content_typeObject



131
132
133
# File 'app/controllers/page_mount_controller.rb', line 131

def content_type
  headers[:content_type].split(';').first
end

#file?Boolean

Returns:

  • (Boolean)


127
128
129
# File 'app/controllers/page_mount_controller.rb', line 127

def file?
  headers.key?(:content_disposition) || FILE_CONTENT_TYPES.include?(content_type)
end

#headersObject



141
142
143
# File 'app/controllers/page_mount_controller.rb', line 141

def headers
  @response.body.headers
end