Read limited size of HTTP content

Discussion in 'Perl Misc' started by Great Deals, Oct 1, 2003.

  1. Great Deals

    Great Deals Guest

    I am trying to stream a real-time stock quote from a none stream http
    html page. The real-time stock quote info is at the some part of the
    page. I only want to download this part not other content. I am very
    sure that http protocal can do this, because such programs as
    net-transport, net-ant, flash-get.. all can resume download broken
    files. I checked their http header from those download manager.
    Besically they just telling the server it is a partial download and
    tells the server the starting point of the download, and it can ends
    at certain point.

    I can not find any PERL module doing this. I think the most low level
    http is Net::Http, but I still could not find anything there that
    meets my need. Here is the code copied from Net::HTTP

    use Net::HTTP;
    my $s = Net::HTTP->new(Host => "www.perl.com) || die $@;
    $s->write_request(GET => "/", 'User-Agent' => "Mozilla/5.0");
    my($code, $mess, %h) = $s->read_response_headers;
    while (1) {
    my $buf;
    my $n = $s->read_entity_body($buf, 1024);
    die "read failed: $!" unless defined $n;
    last unless $n;
    print $buf;
    }

    It looks like $s->read_entity_body($buf, 1024); is close, but it does
    not specify the starting point and ending point. Another question how
    do I exit from the while loop if the maxsize is read. They use die,
    will die quit the whole perl program? Should I use exit instead here?
    Great Deals, Oct 1, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. TheKeith
    Replies:
    20
    Views:
    106,383
    Chris Morris
    Oct 29, 2003
  2. hazz
    Replies:
    6
    Views:
    49,541
    SkyUCHC
    Jun 9, 2010
  3. Phil Z.
    Replies:
    14
    Views:
    13,380
    TongDing
    Jul 22, 2008
  4. Shauniwthanau
    Replies:
    1
    Views:
    402
    Shauniwthanau
    Mar 25, 2010
  5. andrea crotti

    creating size-limited tar files

    andrea crotti, Nov 7, 2012, in forum: Python
    Replies:
    22
    Views:
    524
    Dave Angel
    Nov 14, 2012
Loading...

Share This Page