Class: Net::HTTPGenericRequest

Inherits:
Object
  • Object
show all
Defined in:
lib/aws/s3/extensions.rb

Instance Method Summary collapse

Instance Method Details

#chunk_sizeObject


317
318
319
# File 'lib/aws/s3/extensions.rb', line 317

def chunk_size
  1048576 # 1 megabyte
end

#send_request_with_body_stream(sock, ver, path, f) ⇒ Object

Raises:

  • (ArgumentError)

298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
# File 'lib/aws/s3/extensions.rb', line 298

def send_request_with_body_stream(sock, ver, path, f)
  raise ArgumentError, "Content-Length not given and Transfer-Encoding is not `chunked'" unless content_length() or chunked?
  unless content_type()
    warn 'net/http: warning: Content-Type did not set; using application/x-www-form-urlencoded' if $VERBOSE
    set_content_type 'application/x-www-form-urlencoded'
  end
  write_header sock, ver, path
  if chunked?
    while s = f.read(chunk_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(chunk_size)
      sock.write s
    end
  end
end