$_SERVER['REQUEST_METHOD'], CURLOPT_POSTFIELDS => $body, CURLOPT_HTTPHEADER => $headers, CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 15, )); $response = curl_exec($ch); if ($response === false) { http_response_code(502); header('Content-Type: text/plain'); echo "autodiscover upstream unreachable\n"; curl_close($ch); exit; } $status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE); $contentType = curl_getinfo($ch, CURLINFO_CONTENT_TYPE); curl_close($ch); http_response_code($status ?: 502); header('Content-Type: ' . ($contentType ?: 'application/xml')); echo $response;