Methods
Attributes
[RW] | charset | |
[RW] | chunk_size | |
[RW] | date | |
[RW] | type |
Public Class methods
[ show source ]
# File lib/facets/more/http.rb, line 318 def initialize(body = nil, date = nil, type = nil, charset = nil, boundary = nil) @body = nil @boundary = boundary set_content(body || '', boundary) @type = type @charset = charset @date = date @chunk_size = 4096 end
Public Instance methods
[ show source ]
# File lib/facets/more/http.rb, line 354 def content @body end
[ show source ]
# File lib/facets/more/http.rb, line 337 def dump(dev = '') if @body.respond_to?(:read) begin while true chunk = @body.read(@chunk_size) break if chunk.nil? dev << dump_chunk(chunk) end rescue EOFError end dev << (dump_last_chunk + CRLF) else dev << @body end dev end
[ show source ]
# File lib/facets/more/http.rb, line 358 def set_content(body, boundary = nil) if body.respond_to?(:read) @body = body elsif boundary @body = Message.create_query_multipart_str(body, boundary) else @body = Message.create_query_part_str(body) end end
[ show source ]
# File lib/facets/more/http.rb, line 329 def size if @body.respond_to?(:read) nil else @body.size end end
Private Instance methods
[ show source ]
# File lib/facets/more/http.rb, line 370 def dump_chunk(str) dump_chunk_size(str.size) << (str + CRLF) end
[ show source ]
# File lib/facets/more/http.rb, line 378 def dump_chunk_size(size) sprintf("%x", size) << CRLF end
[ show source ]
# File lib/facets/more/http.rb, line 374 def dump_last_chunk dump_chunk_size(0) end