| Class | Net::HTTPGenericRequest |
| In: |
lib/net_fix.rb
|
| Parent: | Object |
| DEFAULT_LOCAL_READ_SIZE | = | 16*1024 | Default size (in bytes) of the max read from a local source (File, String, etc.) to the user space write buffers for socket IO. |
# File lib/net_fix.rb, line 70
70: def self.local_read_size=(readsize)
71: if(readsize <= 0)
72: return
73: end
74: @@local_read_size = readsize
75: end
# File lib/net_fix.rb, line 93
93: def send_request_with_body(sock, ver, path, body, send_only=nil)
94: self.content_length = body.length
95: delete 'Transfer-Encoding'
96: supply_default_content_type
97: write_header(sock, ver, path) unless send_only == :body
98: sock.write(body) unless send_only == :header
99: end
# File lib/net_fix.rb, line 101
101: def send_request_with_body_stream(sock, ver, path, f, send_only=nil)
102: unless content_length() or chunked?
103: raise ArgumentError,
104: "Content-Length not given and Transfer-Encoding is not `chunked'"
105: end
106: supply_default_content_type
107: write_header(sock, ver, path) unless send_only == :body
108: unless send_only == :header
109: if chunked?
110: while s = f.read(@@local_read_size)
111: sock.write(sprintf("%x\r\n", s.length) << s << "\r\n")
112: end
113: sock.write "0\r\n\r\n"
114: else
115: while s = f.read(@@local_read_size)
116: sock.write s
117: end
118: end
119: end
120: end