Class: Configuration::OutputDataURIImage
- Inherits:
-
OutputImage
- Object
- Scope
- HandlerStatement
- OutputImage
- Configuration::OutputDataURIImage
- Includes:
- PerfStats
- Defined in:
- lib/httpimagestore/configuration/output.rb
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from OutputImage
Methods inherited from Scope
#initialize, node_parsers, #parse, register_node_parser
Constructor Details
This class inherits a constructor from Configuration::OutputImage
Class Method Details
.match(node) ⇒ Object
138 139 140 |
# File 'lib/httpimagestore/configuration/output.rb', line 138 def self.match(node) node.name == 'output_data_uri_image' end |
Instance Method Details
#realize(request_state) ⇒ Object
142 143 144 145 146 147 148 149 150 151 152 153 154 |
# File 'lib/httpimagestore/configuration/output.rb', line 142 def realize(request_state) image = request_state.images[@name] fail "image '#{@name}' needs to be identified first to be used in data URI output" unless image.mime_type cache_control = @cache_control _context = self request_state.output do _context.measure "sending response image data with data URI encoding", "mime type: #{image.mime_type} (image #{image.data.bytesize} bytes)" do res['Cache-Control'] = cache_control if cache_control write 200, 'text/uri-list', "data:#{image.mime_type};base64,#{Base64.strict_encode64(image.data)}" end end end |