CURL = Error 501

CURL = Error 501

am 23.09.2007 02:48:45 von kolodziejczyk.wojtek

Hi,

Friend of my set up for me an apache server (Apache/2.2.0 (Fedora),
php5, mod_rewrite, etc.. - http://serwer2.profprojekt.com.pl/info.php).

Everything works just fine, but i can't send HTTP_Request with data in
POST using CURL. Server returns error:


------------------------------------------------------------ --------------------------
501 Method Not Implemented

Method Not Implemented
POST to /app/webroot/cake_gateway.php not supported.
------------------------------------------------------------ --------------------------

When i'm sending requests with post using forms or ajax server manages
it faultlessly...

Anyone knows where should we looking for bug ?

best
wojtek

Re: CURL = Error 501

am 23.09.2007 03:27:26 von Jerry Stuckle

kolodziejczyk.wojtek@gmail.com wrote:
> Hi,
>
> Friend of my set up for me an apache server (Apache/2.2.0 (Fedora),
> php5, mod_rewrite, etc.. - http://serwer2.profprojekt.com.pl/info.php).
>
> Everything works just fine, but i can't send HTTP_Request with data in
> POST using CURL. Server returns error:
>
>
> ------------------------------------------------------------ --------------------------
> 501 Method Not Implemented
>
> Method Not Implemented
> POST to /app/webroot/cake_gateway.php not supported.
> ------------------------------------------------------------ --------------------------
>
> When i'm sending requests with post using forms or ajax server manages
> it faultlessly...
>
> Anyone knows where should we looking for bug ?
>
> best
> wojtek
>

That's a server response code.

Are you sure you're posting to the correct page? Can you post to THAT
PAGE from a browser?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Re: CURL = Error 501

am 23.09.2007 03:38:32 von kolodziejczyk.wojtek

> That's a server response code.
>
> Are you sure you're posting to the correct page? Can you post to THAT
> PAGE from a browser?
>

yes, when i'm using form to post it works fine

best
wojtek

Re: CURL = Error 501

am 23.09.2007 04:23:52 von Jerry Stuckle

kolodziejczyk.wojtek@gmail.com wrote:
>> That's a server response code.
>>
>> Are you sure you're posting to the correct page? Can you post to THAT
>> PAGE from a browser?
>>
>
> yes, when i'm using form to post it works fine
>
> best
> wojtek
>

It shouldn't be any different.

However, you didn't post any code, and my crystal ball is in the shop,
so I have no idea what your problem might be.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Re: CURL = Error 501

am 23.09.2007 04:50:05 von kolodziejczyk.wojtek

> It shouldn't be any different.
>
> However, you didn't post any code, and my crystal ball is in the shop,
> so I have no idea what your problem might be.
>
> --

yeah, i didn't post any code, because i'm sure that code is correct -
i think that the problem is on server but i don't know where should i
be looking it, anyway here is the code:

function doCurlRequest($data)
{
//This portion taken from SabreAMF (released under LGPL)

$error = NULL;
$ch = curl_init($this->gatewayUrl);

curl_setopt($ch,CURLOPT_POST,1);
curl_setopt($ch,CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch,CURLOPT_TIMEOUT,20);
curl_setopt($ch,CURLOPT_HTTPHEADER,array(AMFPHP_CONTENT_TYPE ));
curl_setopt($ch,CURLOPT_POSTFIELDS,$data);
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);

$result = curl_exec($ch);

if (curl_errno($ch)) {
$this->lastError = 'CURL error: ' . curl_error($ch);
return false;
} else {
curl_close($ch);
}

//Is the result valid so far?
if($result[0] != chr(0))
{
//If chr(0) is not the first char, then this result is not good
//Strip html
$this->lastError = trim(strip_tags(str_replace(' $result)));
return false;
}
return $result;
}

as i say before it's AMFPHP getaway lots of people using it without
any problems. as well it's works great on my local server...

best
wojtek

Re: CURL = Error 501

am 23.09.2007 16:31:54 von kolodziejczyk.wojtek

ok, i've solved the problem

it was about mod_security. Replacing row with

SecRule REQUEST_HEADERS:Content-Type "!(?:^(?:application/x-www-form-
urlencoded$|multipart/form-data;)|text/xml)"
to
SecRule REQUEST_HEADERS:Content-Type "!(?:^(?:application/x-www-form-
urlencoded$|multipart/form-data;)|text/xml|application/x-amf )"

makes it works perfectly.

thanks for your time
best
wojtek