Saturday, 31 August 2013

Using header(), does the header get sent instantly, or after the full script has run?

Using header(), does the header get sent instantly, or after the full
script has run?

I'm working with an external service that polls data from my app. A
requirement of this external service is that I have to let it know that
its request was successful after a maximum of 10 seconds. The problem is
that the script this service connects to might take more than 10 seconds
to execute.
My question is: When I sent the headers via header('HTTP/1.0 200 OK',
true, 200);, will the external service receive this response immediately,
or only after my script has executed completely? Example:
header('HTTP/1.0 200 OK', true, 200);
some_function_that_takes_20_seconds()
Will the response header be sent immediately or only after 20 seconds?

No comments:

Post a Comment