Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fix when passing content body #20

Open
wants to merge 1 commit into from

2 participants

@jdichev
  1. Use raw encoded request body for POST request body setting and not a parameters array

  2. Pass content type fields as well

@jdichev jdichev 1. Use raw encoded request body for POST request body setting and not…
… parameters array

2. Pass content type fields as well
740fc45
@kyrylo kyrylo commented on the diff
ba-simple-proxy.php
@@ -183,6 +183,8 @@
curl_setopt( $ch, CURLOPT_USERAGENT, $_GET['user_agent'] ? $_GET['user_agent'] : $_SERVER['HTTP_USER_AGENT'] );
+ curl_setopt( $ch, CURLOPT_HTTPHEADER, array( "Content-Type: " . $_SERVER['HTTP_CONTENT_TYPE'] ) );
@kyrylo
kyrylo added a note

HTTP_CONTENT_TYPE must be CONTENT_TYPE. See section 4.1.3 from The Common Gateway Interface (CGI) Version 1.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 16, 2012
  1. @jdichev

    1. Use raw encoded request body for POST request body setting and not…

    jdichev authored
    … parameters array
    
    2. Pass content type fields as well
This page is out of date. Refresh to see the latest.
Showing with 3 additions and 1 deletion.
  1. +3 −1 ba-simple-proxy.php
View
4 ba-simple-proxy.php
@@ -161,7 +161,7 @@
if ( strtolower($_SERVER['REQUEST_METHOD']) == 'post' ) {
curl_setopt( $ch, CURLOPT_POST, true );
- curl_setopt( $ch, CURLOPT_POSTFIELDS, $_POST );
+ curl_setopt( $ch, CURLOPT_POSTFIELDS, $HTTP_RAW_POST_DATA );
}
if ( $_GET['send_cookies'] ) {
@@ -183,6 +183,8 @@
curl_setopt( $ch, CURLOPT_USERAGENT, $_GET['user_agent'] ? $_GET['user_agent'] : $_SERVER['HTTP_USER_AGENT'] );
+ curl_setopt( $ch, CURLOPT_HTTPHEADER, array( "Content-Type: " . $_SERVER['HTTP_CONTENT_TYPE'] ) );
@kyrylo
kyrylo added a note

HTTP_CONTENT_TYPE must be CONTENT_TYPE. See section 4.1.3 from The Common Gateway Interface (CGI) Version 1.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+
list( $header, $contents ) = preg_split( '/([\r\n][\r\n])\\1/', curl_exec( $ch ), 2 );
$status = curl_getinfo( $ch );
Something went wrong with that request. Please try again.