Class: HTTP::Message::Body
- Inherits:
-
Object
- Object
- HTTP::Message::Body
- Defined in:
- lib/http-access2/http.rb
Instance Attribute Summary collapse
-
#charset ⇒ Object
Returns the value of attribute charset.
-
#chunk_size ⇒ Object
Returns the value of attribute chunk_size.
-
#date ⇒ Object
Returns the value of attribute date.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
- #content ⇒ Object
- #dump(dev = '') ⇒ Object
-
#initialize(body = nil, date = nil, type = nil, charset = nil, boundary = nil) ⇒ Body
constructor
A new instance of Body.
- #set_content(body, boundary = nil) ⇒ Object
- #size ⇒ Object
Constructor Details
#initialize(body = nil, date = nil, type = nil, charset = nil, boundary = nil) ⇒ Body
Returns a new instance of Body.
293 294 295 296 297 298 299 300 301 302 |
# File 'lib/http-access2/http.rb', line 293 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 |
Instance Attribute Details
#charset ⇒ Object
Returns the value of attribute charset.
291 292 293 |
# File 'lib/http-access2/http.rb', line 291 def charset @charset end |
#chunk_size ⇒ Object
Returns the value of attribute chunk_size.
291 292 293 |
# File 'lib/http-access2/http.rb', line 291 def chunk_size @chunk_size end |
#date ⇒ Object
Returns the value of attribute date.
291 292 293 |
# File 'lib/http-access2/http.rb', line 291 def date @date end |
#type ⇒ Object
Returns the value of attribute type.
291 292 293 |
# File 'lib/http-access2/http.rb', line 291 def type @type end |
Instance Method Details
#content ⇒ Object
329 330 331 |
# File 'lib/http-access2/http.rb', line 329 def content @body end |
#dump(dev = '') ⇒ Object
312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 |
# File 'lib/http-access2/http.rb', line 312 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 |
#set_content(body, boundary = nil) ⇒ Object
333 334 335 336 337 338 339 340 341 |
# File 'lib/http-access2/http.rb', line 333 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 |
#size ⇒ Object
304 305 306 307 308 309 310 |
# File 'lib/http-access2/http.rb', line 304 def size if @body.respond_to?(:read) nil else @body.size end end |