class Net::HTTPGenericRequest

Constants

DEFAULT_LOCAL_READ_SIZE

Default size (in bytes) of the max read from a local source (File, String, etc.) to the user space write buffers for socket IO.

Public Class Methods

local_read_size=(readsize) click to toggle source
# File lib/net_fix.rb, line 70
def self.local_read_size=(readsize)
  if(readsize <= 0)
    return
  end
  @@local_read_size = readsize
end
local_read_size?() click to toggle source
# File lib/net_fix.rb, line 77
def self.local_read_size?()
  @@local_read_size
end

Private Instance Methods

send_request_with_body(sock, ver, path, body, send_only=nil) click to toggle source
# File lib/net_fix.rb, line 93
def send_request_with_body(sock, ver, path, body, send_only=nil)
  self.content_length = body.length
  delete 'Transfer-Encoding'
  supply_default_content_type
  write_header(sock, ver, path) unless send_only == :body
  sock.write(body)              unless send_only == :header
end
send_request_with_body_stream(sock, ver, path, f, send_only=nil) click to toggle source
# File lib/net_fix.rb, line 101
def send_request_with_body_stream(sock, ver, path, f, send_only=nil)
  unless content_length() or chunked?
    raise ArgumentError,
        "Content-Length not given and Transfer-Encoding is not `chunked'"
  end
  supply_default_content_type
  write_header(sock, ver, path) unless send_only == :body
  unless send_only == :header
    if chunked?
      while s = f.read(@@local_read_size)
        sock.write(sprintf("%x\r\n", s.length) << s << "\r\n")
      end
      sock.write "0\r\n\r\n"
    else
      while s = f.read(@@local_read_size)
        sock.write s
      end
    end
  end
end