From 83c9b14cc22855f5a87001bb082581e9de8a4ba1 Mon Sep 17 00:00:00 2001 From: Ido Green Date: Thu, 10 May 2012 13:28:55 +0300 Subject: [PATCH] 1. Report errors in cUrl. 2. Add a comment with an option (I've used many times) to Not verify SSL certificates. It's good option for internal usage. --- ba-simple-proxy.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/ba-simple-proxy.php b/ba-simple-proxy.php index b1fa6e8..ca97917 100644 --- a/ba-simple-proxy.php +++ b/ba-simple-proxy.php @@ -181,9 +181,16 @@ curl_setopt( $ch, CURLOPT_HEADER, true ); curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); - curl_setopt( $ch, CURLOPT_USERAGENT, $_GET['user_agent'] ? $_GET['user_agent'] : $_SERVER['HTTP_USER_AGENT'] ); + // in case you wish Not to confirm the CA for your server (e.g. it's inside your org) + // curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER , false); - list( $header, $contents ) = preg_split( '/([\r\n][\r\n])\\1/', curl_exec( $ch ), 2 ); + curl_setopt( $ch, CURLOPT_USERAGENT, $_GET['user_agent'] ? $_GET['user_agent'] : $_SERVER['HTTP_USER_AGENT'] ); + $res = curl_exec( $ch ); + if ($res === FALSE) { + // in case we have errors - let's report them! + die(curl_error($ch)); + } + list( $header, $contents ) = preg_split( '/([\r\n][\r\n])\\1/', $res, 2 ); $status = curl_getinfo( $ch );