PHP headers question

 
Post new topic   Reply to topic    Aprelium Forum Index -> PHP
View previous topic :: View next topic  
Author Message
TRUSTAbyss
-


Joined: 29 Oct 2003
Posts: 3752
Location: USA, GA

PostPosted: Thu Jul 26, 2007 9:01 am    Post subject: PHP headers question Reply with quote

Hello Everyone,

I'm writing a PHP script that limits a certain number of connections to a file but I want to have a way to tell the download resuming clients when the maximum number of connections have been reached so that it stops at a certain amount of connections. What header can I use?

Edit: I believe the Error 503 will fix this. I think I fixed the problem but feel free to post if you know of a better way.

Sample Code:
Code:
<?php
$connects = 2; // Active connections
$max_connects = 4; // Maximum connections allowed

if ($connects <= $max_connects)
{
    ...send the file
}
else
{
    header("HTTP/1.1 503 Service Unavailable");
    header("Retry-After: 30"); // let the client retry every 30 secs.
}
?>


Kind regards, Josh


Last edited by TRUSTAbyss on Thu Jul 26, 2007 5:58 pm; edited 1 time in total
Back to top View user's profile Send private message Visit poster's website
roganty
-


Joined: 08 Jun 2004
Posts: 357
Location: Bristol, UK

PostPosted: Thu Jul 26, 2007 11:03 am    Post subject: Re: PHP headers question Reply with quote

TRUSTAbyss wrote:

Code:
<?php
$connects = 2; // Active connections
$max_connects = 4; // Maximum connections allowed

if ($connects <= $max_connects)
{
    ...send the file
}
else
{
    header("HTTP/1.1 503 Service Unavailable");
}
?>


According to the following url:
http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.5.4
You could send a Retry-After header
_________________
Anthony R

Roganty
| Links-Links.co.uk
Back to top View user's profile Send private message Visit poster's website
TRUSTAbyss
-


Joined: 29 Oct 2003
Posts: 3752
Location: USA, GA

PostPosted: Thu Jul 26, 2007 5:59 pm    Post subject: Reply with quote

Thanks roganty! I think the syntax is correct now.
Back to top View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> PHP All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group