Skip to content

Commit

Permalink
Support absolute URLs in long-polling headers
Browse files Browse the repository at this point in the history
  • Loading branch information
cdhowie committed May 31, 2011
1 parent 2041820 commit 061a033
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions htdocs/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,17 @@ function set_lp_header($headers, $id, $url) {
$pieces = explode(': ', $header, 2);

if (count($pieces) == 2 && $pieces[0] == 'X-Long-Polling') {
$parts = parse_url($url);

$lpurl = sprintf('%s:https://%s%s%s',
$parts['scheme'],
$parts['host'],
(isset($parts['port']) ? (':' . $parts['port']) : ''),
$pieces[1]);
if (strpos($pieces[1], ':https://') !== FALSE) {
$lpurl = $pieces[1];
} else {
$parts = parse_url($url);

$lpurl = sprintf('%s:https://%s%s%s',
$parts['scheme'],
$parts['host'],
(isset($parts['port']) ? (':' . $parts['port']) : ''),
$pieces[1]);
}

header(sprintf('X-Long-Polling: %s?lpurl=%s&pool=%d',
$_SERVER['PHP_SELF'], urlencode($lpurl), $id));
Expand Down

0 comments on commit 061a033

Please sign in to comment.