Skip to content

Commit

Permalink
fixes cowboy#1 on cowboy/php-simple-proxy
Browse files Browse the repository at this point in the history
Change all UNDEFINED notices to not trigger (use array_key_exists instead)
  • Loading branch information
benkaiser committed Feb 3, 2015
1 parent 5dbb1be commit 159651f
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions ba-simple-proxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@
curl_setopt( $ch, CURLOPT_POST, true );
curl_setopt( $ch, CURLOPT_POSTFIELDS, $_POST );
}
if ( $_GET['send_cookies'] ) {

if ( array_key_exists('send_cookies', $_GET) ) {
$cookie = array();
foreach ( $_COOKIE as $key => $value ) {
$cookie[] = $key . '=' . $value;
Expand All @@ -180,9 +180,9 @@
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, true );
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'] );

curl_setopt( $ch, CURLOPT_USERAGENT, array_key_exists('user_agent', $_GET) ? $_GET['user_agent'] : $_SERVER['HTTP_USER_AGENT'] );

list( $header, $contents ) = preg_split( '/([\r\n][\r\n])\\1/', curl_exec( $ch ), 2 );

$status = curl_getinfo( $ch );
Expand All @@ -193,7 +193,7 @@
// Split header text into an array.
$header_text = preg_split( '/[\r\n]+/', $header );

if ( $_GET['mode'] == 'native' ) {
if ( array_key_exists('mode', $_GET) && $_GET['mode'] == 'native' ) {
if ( !$enable_native ) {
$contents = 'ERROR: invalid mode';
$status = array( 'http_code' => 'ERROR' );
Expand All @@ -214,7 +214,7 @@
$data = array();

// Propagate all HTTP headers into the JSON data object.
if ( $_GET['full_headers'] ) {
if ( array_key_exists('full_headers', $_GET) ) {
$data['headers'] = array();

foreach ( $header_text as $header ) {
Expand All @@ -226,7 +226,7 @@
}

// Propagate all cURL request / response info to the JSON data object.
if ( $_GET['full_status'] ) {
if ( array_key_exists('full_status', $_GET) ) {
$data['status'] = $status;
} else {
$data['status'] = array();
Expand Down

0 comments on commit 159651f

Please sign in to comment.