<?php
$req=json_decode(file_get_contents(__DIR__.'/private-request.json'),true);$lane=getenv('PM_LANE');$port=$lane==='B'?18341:18342;
foreach($req['cases'] as $case){
 if($case['label']==='setAll')continue;
 $c=curl_init('http://127.0.0.1:'.$port.$case['path']);curl_setopt_array($c,[CURLOPT_POST=>true,CURLOPT_POSTFIELDS=>http_build_query($case['params']),CURLOPT_RETURNTRANSFER=>true,CURLOPT_HTTPHEADER=>['token: '.$req['token'],'X-CDX-Case: '.$case['label']],CURLOPT_CONNECTTIMEOUT=>5,CURLOPT_TIMEOUT=>30]);
 $body=curl_exec($c);$info=curl_getinfo($c);$err=curl_error($c);curl_close($c);if($body===false)throw new RuntimeException('HTTP client failed');
 file_put_contents(__DIR__.'/private-retest-'.$case['label'].'.httpbody',$body);chmod(__DIR__.'/private-retest-'.$case['label'].'.httpbody',0600);
 $d=json_decode($body,true);$summary=['case'=>$case['label'],'HTTP'=>$info['http_code'],'business_code'=>$d['code']??null,'bytes'=>strlen($body),'body_sha256'=>hash('sha256',$body),'duration_seconds'=>$info['total_time'],'client_error'=>$err];
 file_put_contents(__DIR__.'/private-retest-'.$case['label'].'.http.json',json_encode($summary,JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE));chmod(__DIR__.'/private-retest-'.$case['label'].'.http.json',0600);echo json_encode($summary,JSON_UNESCAPED_UNICODE),"\n";
}
