Class: Net::PTTH::OutgoingRequest

Inherits:
Struct
  • Object
show all
Defined in:
lib/net/ptth/outgoing_request.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#reqObject

Returns the value of attribute req

Returns:

  • (Object)

    the current value of req



2
3
4
# File 'lib/net/ptth/outgoing_request.rb', line 2

def req
  @req
end

Instance Method Details

#to_sObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/net/ptth/outgoing_request.rb', line 3

def to_s
  package = "#{req.method} #{req.path} HTTP/1.1#{Net::PTTH::CRLF}"

  req["Content-Length"] ||= req.body ? req.body.size : 0

  req.each_header do |header, value|
    header_parts = header.split("-").map(&:capitalize)
    package += "#{header_parts.join("-")}: #{value}#{Net::PTTH::CRLF}"
  end

  package += Net::PTTH::CRLF

  package += req.body if req.body
  package
end