Sha256: e5e0e4bb333c11d0f82e7ba0d06b5d1a0a570059a240dbd8d5966d5f6ff6a283
Contents?: true
Size: 760 Bytes
Versions: 2
Compression:
Stored size: 760 Bytes
Contents
# frozen_string_literal: true require_relative '../utils/http_status_code' ## # Module responsible to filter and mount HTTP responses module ResponseDataFilter include HttpStatusCode def self.mount_response(status, headers, body) "#{mount_first_response_line(status, headers)}#{mount_response_headers(headers)}#{body}" end def self.mount_first_response_line(status, headers) separator = " \r\n\r\n" separator = " \r\n" unless headers.nil? "HTTP/1.1 #{status} #{HTTP_STATUS_CODE_MAP[status]}#{separator}" end def self.mount_response_headers(headers) return '' if headers.nil? response = '' headers.each do |key, value| response += "#{key}: #{value}\r\n" end response += "\r\n" response end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
macaw_framework-1.3.21 | lib/macaw_framework/data_filters/response_data_filter.rb |
macaw_framework-1.3.1 | lib/macaw_framework/data_filters/response_data_filter.rb |