Class: WEBrick::HTTPResponse::ChunkedWrapper
- Inherits:
-
Object
- Object
- WEBrick::HTTPResponse::ChunkedWrapper
- Defined in:
- lib/webrick/httpresponse.rb
Instance Method Summary collapse
- #<<(*buf) ⇒ Object
-
#initialize(socket, resp) ⇒ ChunkedWrapper
constructor
A new instance of ChunkedWrapper.
- #write(buf) ⇒ Object
Constructor Details
#initialize(socket, resp) ⇒ ChunkedWrapper
Returns a new instance of ChunkedWrapper.
532 533 534 535 |
# File 'lib/webrick/httpresponse.rb', line 532 def initialize(socket, resp) @socket = socket @resp = resp end |
Instance Method Details
#<<(*buf) ⇒ Object
550 551 552 553 |
# File 'lib/webrick/httpresponse.rb', line 550 def <<(*buf) write(buf) self end |
#write(buf) ⇒ Object
537 538 539 540 541 542 543 544 545 546 547 548 |
# File 'lib/webrick/httpresponse.rb', line 537 def write(buf) return 0 if buf.empty? socket = @socket @resp.instance_eval { size = buf.bytesize data = "#{size.to_s(16)}#{CRLF}#{buf}#{CRLF}" socket.write(data) data.clear @sent_size += size size } end |