Skip to content

Instantly share code, notes, and snippets.

@jonasdeherdt
Created June 4, 2014 13:32
Show Gist options
  • Save jonasdeherdt/49a11c91131884ac9e36 to your computer and use it in GitHub Desktop.
Save jonasdeherdt/49a11c91131884ac9e36 to your computer and use it in GitHub Desktop.
proxy
<?php
$post_data = $HTTP_RAW_POST_DATA;
$header[] = "Content-type: text/xml";
$header[] = "Content-length: ".strlen($post_data);
$ch = curl_init( $_GET['url'] );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
if ( strlen($post_data)>0 ){
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
}
$response = curl_exec($ch);
$response_headers = curl_getinfo($ch);
if (curl_errno($ch)) {
print curl_error($ch);
} else {
curl_close($ch);
header( 'Content-type: ' . $response_headers['content-type']);
print $response;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment