4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/htttee/client/ext/net/http.rb', line 4
def send_request_with_body_stream(sock, ver, path, f)
unless content_length() or chunked?
raise ArgumentError,
"Content-Length not given and Transfer-Encoding is not `chunked'"
end
supply_default_content_type
sock, ver, path
if chunked?
begin
while s = f.readpartial(1024)
sock.write(sprintf("%x\r\n", s.length) << s << "\r\n")
end
rescue EOFError
sock.write "0\r\n\r\n"
end
else
while s = f.read(1024)
sock.write s
end
end
end
|