Support the ongoing development of Laravel.io →
Requests Testing
Last updated 4 months ago.
0

let me study more tomorrow and elaborate more on the question thread. on my second thought what i want was not a delay in 301 response. what i really want was real resource, say video/mp4 after routes.php's 301.

Last updated 4 months ago.
0

If the goal is waiting on a response from a 3rd party service or stream there are lots of ways to do it without sleeping.

The most commonly used method for this is using event listeners usually on state changes.

This is very common in Ajax loading and looks something like this.

var my_request = new XMLHttpRequest();

//create a function that fires each time the request state changes
my_request.onreadystatechange = function()
{
    // check to see if the state of the request is ready and valid
    if (this.readyState == 4 && this.status == 200) 
    {
        var response = this.responseText;
        alert(response);
    }
}
my_request.open("get", "http://localhost/";, true);
my_request.send()

You can also do this with CURL in php..... I am not sure if this is what you are needing though.

Last updated 4 months ago.
0

I end up doing like DrPrez's recommendation, sleep(). I'll have to keep studying how to throttle the actual resource response at server side.

Last updated 4 months ago.
0

Thanks for your idea. I think you meant setTimeOut in if test block. What I want was delay in server side, not in client side. Anyway thanks a lot.

IanSirkit said:

Last updated 4 months ago.
0

Update: I was not good at what I wanted to. I should have titled this as 'Throttle response throughput' or something. Anyway I found a solution and made it through nginix config. Thanks community.

Last updated 4 months ago.
0

Sign in to participate in this thread!

LaraJobs

Your banner here too?

appkr appkr Joined 20 Mar 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

The Laravel portal for problem solving, knowledge sharing and community building.

© 2022 Laravel.io - All rights reserved.