class WabSarvar::Response
Attributes
code[R]
Public Class Methods
new(code:, headers: [], data: "")
click to toggle source
# File lib/wab_sarvar/response.rb, line 5 def initialize(code:, headers: [], data: "") @code = code @data = data @headers = headers end
Public Instance Methods
body()
click to toggle source
# File lib/wab_sarvar/response.rb, line 19 def body "#{@data}\r\n" end
headers()
click to toggle source
# File lib/wab_sarvar/response.rb, line 11 def headers "HTTP/1.1 #{@code}\r\n" + "Content-Length: #{@data.bytesize}\r\n" + # "Content-Type: text/html" + @headers.join("\r\n") + "\r\n" end
send(client)
click to toggle source
# File lib/wab_sarvar/response.rb, line 23 def send(client) puts "Respond with #{@code}" response = headers + body client.write(response) end