سؤال

I'm trying to send a XML string to a controller using winhttp.winhttprequest.5.1 from a remote server via POST. Doing so on my dev machine runs perfectly fine (hosting client and server on the same machine, same IP). Nevertheless, when my application is deployed on the production server, the POST array is empty.

I think it might be due to CSRF protection, but even if I disable it in config.yml, my controller still get empty data. So, I'm quite stuck right here, would appreciate any help.

Sending data using winhttp.winhttprequest.5.1

loObj.Open("POST", url, .F.)
loObj.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded")
loObj.Send("lcFile=" + parsedContent)

Symfony2 Controller :

public function getStockFromLogisticsXMLStringAction(Request $request)
{
    $request = $this->get('request');

    $xml = "";
    $output = $this->get('webservice.response');

    if ($request->getMethod() == 'POST') 
        $xml = $request->request->get('lcFile');
...
}

Request dump :

  • Dev machine : [request] => Symfony\Component\HttpFoundation\ParameterBag Object (
    [parameters:protected] => Array (
    [lcFile] => A1005LNBsLNBs5false2013-05-30T12:06:52201 blablabla

  • Prod machine : [request] => Symfony\Component\HttpFoundation\ParameterBag Object (
    [parameters:protected] => Array ( ) )
    [query] => Symfony\Component\HttpFoundation\ParameterBag Object (
    [parameters:protected] => Array

Both environment are running Apache with PHP 5.4.

The fact I'm suspecting some CSRF protection issue is that if I send the exact same XML string to a pure PHP script on the production server dumping the POST data into a file, it works. If I send those datas to a Symfony controller, the request is empty...

Thank you.

هل كانت مفيدة؟

المحلول

Using OVH as a production server, it set a http firewall unabling to send POST data to controllers (.ovhconfig on root directory). Removing or setting it right allowed me to send those data.

 http.firewall=none

Thanks for helping anyway.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top