1
0

2 Commitit 5bc85ba20f ... 20ff553d5c

Tekijä SHA1 Viesti Päivämäärä
  pezcurrel 20ff553d5c Updated “ckrl()” to the “lib” version 2 viikkoa sitten
  pezcurrel 51b356bf14 Updated to the “lib” version 2 viikkoa sitten
2 muutettua tiedostoa jossa 3 lisäystä ja 6 poistoa
  1. 1 1
      web/clitools/getinstinfo.php
  2. 2 5
      web/lib/ckratelimit.php

+ 1 - 1
web/clitools/getinstinfo.php

@@ -1206,7 +1206,7 @@ function ckrl($headers,$ctx) {
 	$res=ckratelimit($headers);
 	if (!$res['ok']) {
 		eecho(2,"{$ctx}: ckratelimit: {$res['error']}.\n");
-	} elseif ($res['sleep']>0) {
+	} elseif ($res['remaining']==0) {
 		eecho(2,"{$ctx}: ckratelimit: x-ratelimit-remaining is 0, sleeping for ".ght($res['sleep']).' (until '.date('c',time()+$res['sleep']).") ...\n");
 		sleep($res['sleep']);
 	}

+ 2 - 5
web/lib/ckratelimit.php

@@ -19,17 +19,14 @@ function ckratelimit($headers) {
 	if (!is_int($reset)) return ['ok'=>false,'error'=>'«x-ratelimit-reset» header could not be converted to a unix timestamp'];
 	// don't do the one on the line below, since it happens lots of times
 	//if ($reset<$date) return ['ok'=>false,'error'=>'the unix timestamp parsed from «x-ratelimit-reset» header is less than the unix timestamp parsed from «date» header'];
-	if ($remaining==0)
-		return ['ok'=>true,'sleep'=>$reset-$date+1,'remaining'=>$remaining];
-	else
-		return ['ok'=>true,'sleep'=>0,'remaining'=>$remaining];
+	return ['ok'=>true,'sleep'=>$reset-$date+1,'remaining'=>$remaining];
 }
 
 /*
 // test
 $context=[
 	'http'=>[
-		'header'=>'Accept: application/json'.RN
+		'header'=>"Accept: application/json\r\n";
 	]
 ];
 $context=stream_context_create($context);