Sha256: d1a1a571489213e2d9f910205b4e86c88a651d4adaedf96c1e52edfcd5bfa227
Contents?: true
Size: 765 Bytes
Versions: 4
Compression:
Stored size: 765 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 nil if headers.nil? response = "" headers.each do |key, value| response += "#{key}: #{value}\r\n" end response += "\r\n\r\n" response end end
Version data entries
4 entries across 4 versions & 1 rubygems