Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9104899
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T01:58:11+00:00 2026-06-17T01:58:11+00:00

I am using rolling curl to get data from 40 other websites. As soon

  • 0

I am using rolling curl to get data from 40 other websites. As soon as the results are available for a website, they are being sent out immediately by using chunks.

To implement that , I added following headers :-

header("Transfer-encoding: chunked");
flush();

I also used a function to print the chunks :-

function print_chunks($chunk){
    $chunk = json_encode($tempArray);
    echo sprintf("%x\r\n", strlen(($chunk)));
    print_r($chunk);
   echo "\r\n";
   flush();
}

In my case , every chunk is some data in JSON format, whose size can be any value other than zero.

At the client side, I am using this to handle my responses :-

xml.onprogress = function () {
alert("Triggered");
}

That triggers only twice for about 40 calls . I guess many responses are getting merged before they are actually sent out. This leads to severely bad performance as results are sent out not individually, but only after all results have been sent out.Is it due to small size of individual responses ?

Here is the actual handle which sends chunked data to check out.

Update :

Is there any constraint on the minimum size of individual chunks ? If I sent only simple small string chunks, it sends all of my chunks together.

This is the complete code that i used. Even if I have made 10 chunks here, I get all of them together after 20 seconds :-

<?php
header("Transfer-encoding: chunked");
flush();


function dump_chunk($chunk)
{
    echo sprintf("%x\r\n", strlen($chunk));
    echo $chunk;
    echo "\r\n";
    flush();
}

$string = "Hello World, This is chunk1";
$string1 = "Hello World, This is chunk2";
$string2 = "Hello World, This is chunk3";
$string3 = "Hello World, This is chunk4";
$string4 = "Hello World, This is chunk5";
$string5 = "Hello World, This is chunk6";
$string6 = "Hello World, This is chunk7";
$string7 = "Hello World, This is chunk8";
$string8 = "Hello World, This is chunk9";
$string9 = "Hello World, This is chunk10";
$string10 = "";

dump_chunk($string);
sleep(2);
dump_chunk($string1);
sleep(2);
dump_chunk($string2);
sleep(2);
dump_chunk($string3);
sleep(2);
dump_chunk($string4);
sleep(2);
dump_chunk($string5);
sleep(2);
dump_chunk($string6);
sleep(2);
dump_chunk($string7);
sleep(2);
dump_chunk($string8);
sleep(2);
dump_chunk($string9);
sleep(2);
dump_chunk($string10);

?>

Please comment if I am unclear in asking my doubt.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T01:58:12+00:00Added an answer on June 17, 2026 at 1:58 am

    Using flush() to push the content to the browser, at the end of your print_chunksfunction, should work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to calculate a rolling mean using plyr. The data is at
Setup: I'm looking for insight into using a ABPersonViewContoller without getting data from the
I'm using a 'rolling' cURL multi implementation (like this SO post , based on
I'm rolling my own PeoplePicker, using the following code to get all my contacts:
I'm rolling back from Spring Security 3.1.0.m1 to 3.0.5 but I'm using the security=none
Using the Redis info command, I am able to get all the stats of
Using Location.getBearing(); I seem to get randomly changing bearings. Aka, I can turn the
I'm using log4net to log write log message to a rolling log file. Now
I'm using the LogInfo() method to log to a rolling flat file, but I
We are using log4net to create our logfiles from Windows services, and we are

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.