Method: HTTPClient::Session#get_body

Defined in:
lib/httpclient/session.rb

#get_body(&block) ⇒ Object



577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
# File 'lib/httpclient/session.rb', line 577

def get_body(&block)
  begin
    read_header if @state == :META
    return nil if @state != :DATA
    if @transparent_gzip_decompression
      block = content_inflater_block(@content_encoding, block)
    end
    if @chunked
      read_body_chunked(&block)
    elsif @content_length
      read_body_length(&block)
    else
      read_body_rest(&block)
    end
  rescue
    close
    raise
  end
  if eof?
    if @next_connection
      @state = :WAIT
    else
      close
    end
  end
  nil
end