Send async rpc via POST?

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

Send async rpc via POST?

Philipp Wabinski

Hello,

is it possible to send a async rpc call from the frontend to the backend via
POST?

When I echo the $_SERVER["REQUEST_METHOD"] in the php backend, it always
returns "GET".

Is there a setting or sometjhing like that to use POST?

Thanks for your answer

Philipp
--
View this message in context: http://www.nabble.com/Send-async-rpc-via-POST--tp18606916p18606916.html
Sent from the qooxdoo-devel mailing list archive at Nabble.com.


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: Send async rpc via POST?

asaris
Philipp,

qx.io.remote.Rpc does send request in raw POST.

You can access POST content by file_get_contents('php://input');

But why don't you use PHP RPC backend located at
qooxdoo/backend/php/services/?

asaris

Philipp Wabinski wrote:

> Hello,
>
> is it possible to send a async rpc call from the frontend to the backend via
> POST?
>
> When I echo the $_SERVER["REQUEST_METHOD"] in the php backend, it always
> returns "GET".
>
> Is there a setting or sometjhing like that to use POST?
>
> Thanks for your answer
>
> Philipp
>  

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: Send async rpc via POST?

Andreas Junghans
In reply to this post by Philipp Wabinski
Hi Philipp,

Am 23.07.2008 um 11:22 schrieb Philipp Wabinski:

> is it possible to send a async rpc call from the frontend to the  
> backend via
> POST?
>
> When I echo the $_SERVER["REQUEST_METHOD"] in the php backend, it  
> always
> returns "GET".
>
> Is there a setting or sometjhing like that to use POST?

You're probably making cross-domain requests (i.e. your PHP backend is  
not in the same domain as the page from which the request is made).  
This is also the case when you load your page directly from the  
filesystem (via file:// url).

In the cross-domain case, it's not possible to use POST requests. You  
either have to use GET or make sure that your HTML page and the RPC  
server are in the same domain (and set the crossDomain property to  
false in your Rpc object).

Regards,

   Andreas


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: Send async rpc via POST?

Philipp Wabinski
In reply to this post by asaris

Hello asaris,

I use the qooxdoo php backend.


When I cut this from the index php:

if ($_SERVER["REQUEST_METHOD"] == "POST")
{
    /*
     * For POST data, the only acceptable content type is application/json.
     */
    switch($_SERVER["CONTENT_TYPE"])
    {
    case "application/json":
        /* We found literal POSTed json-rpc data (we hope) */
        $input = file_get_contents('php://input');
        $jsonInput = $json->decode($input);
        break;

    default:
        /*
         * This request was not issued with JSON-RPC so echo the error
rather
         * than issuing a JsonRpcError response.
         */
        echo
            "JSON-RPC request expected; " .
            "unexpected data received";
        exit;
    }
}
else if ($_SERVER["REQUEST_METHOD"] == "GET" &&
         isset($_GET["_ScriptTransport_id"]) &&
         $_GET["_ScriptTransport_id"] != ScriptTransport_NotInUse &&
         isset($_GET["_ScriptTransport_data"]))
{
    /* We have what looks like a valid ScriptTransport request */
    $scriptTransportId = $_GET["_ScriptTransport_id"];
    $error->SetScriptTransportId($scriptTransportId);
    $input = $_GET["_ScriptTransport_data"];
    $jsonInput = $json->decode(get_magic_quotes_gpc()
                               ? stripslashes($input)
                               : $input);
}




and paste ethe following:

if ($_SERVER["REQUEST_METHOD"] == "POST")
{
    echo "POST";
}
else if ($_SERVER["REQUEST_METHOD"] == "GET" &&
         isset($_GET["_ScriptTransport_id"]) &&
         $_GET["_ScriptTransport_id"] != ScriptTransport_NotInUse &&
         isset($_GET["_ScriptTransport_data"]))
{
    echo "GET";
}

"GET" is always returned.

The index.php doesn`t receive the data via POST :(

The Problem is that some of my requests are to long to send them via GET.

Please help!!

Philipp


asaris wrote:

>
> Philipp,
>
> qx.io.remote.Rpc does send request in raw POST.
>
> You can access POST content by file_get_contents('php://input');
>
> But why don't you use PHP RPC backend located at
> qooxdoo/backend/php/services/?
>
> asaris
>
> Philipp Wabinski wrote:
>> Hello,
>>
>> is it possible to send a async rpc call from the frontend to the backend
>> via
>> POST?
>>
>> When I echo the $_SERVER["REQUEST_METHOD"] in the php backend, it always
>> returns "GET".
>>
>> Is there a setting or sometjhing like that to use POST?
>>
>> Thanks for your answer
>>
>> Philipp
>>  
>
>

--
View this message in context: http://www.nabble.com/Send-async-rpc-via-POST--tp18606916p18607247.html
Sent from the qooxdoo-devel mailing list archive at Nabble.com.


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: Send async rpc via POST?

Philipp Wabinski
In reply to this post by Andreas Junghans

Hi Andreas,

you were right! Thanks for your answer!

I have set the cross domain to true:

this.rpc.setCrossDomain(false);

I set it to false and the data was send via POST :) !

I use qooxdoo since 0.6.3 and I`m really sure that cross domain hast to be
set to true to make an async call in older Versions.

Do you know since which version it doesn`t has to be set anymore to true?

Thanks for the quick help

Philipp



Andreas Junghans wrote:

>
> Hi Philipp,
>
> Am 23.07.2008 um 11:22 schrieb Philipp Wabinski:
>
>> is it possible to send a async rpc call from the frontend to the  
>> backend via
>> POST?
>>
>> When I echo the $_SERVER["REQUEST_METHOD"] in the php backend, it  
>> always
>> returns "GET".
>>
>> Is there a setting or sometjhing like that to use POST?
>
> You're probably making cross-domain requests (i.e. your PHP backend is  
> not in the same domain as the page from which the request is made).  
> This is also the case when you load your page directly from the  
> filesystem (via file:// url).
>
> In the cross-domain case, it's not possible to use POST requests. You  
> either have to use GET or make sure that your HTML page and the RPC  
> server are in the same domain (and set the crossDomain property to  
> false in your Rpc object).
>
> Regards,
>
>    Andreas
>
>

--
View this message in context: http://www.nabble.com/Send-async-rpc-via-POST--tp18606916p18607496.html
Sent from the qooxdoo-devel mailing list archive at Nabble.com.


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: Send async rpc via POST?

Andreas Junghans
Hi Philipp,

Am 23.07.2008 um 12:02 schrieb Philipp Wabinski:

> you were right! Thanks for your answer!
>
> I have set the cross domain to true:
>
> this.rpc.setCrossDomain(false);
>
> I set it to false and the data was send via POST :) !
>
> I use qooxdoo since 0.6.3 and I`m really sure that cross domain hast  
> to be
> set to true to make an async call in older Versions.

This would be a very odd bug - I don't recall anything like that, but  
I might be wrong.

> Do you know since which version it doesn`t has to be set anymore to  
> true?

Sorry, I don't know about any such bug.

Regards,

   Andreas


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: Send async rpc via POST?

Philipp Wabinski

Hi Andreas,

I have another error right now. When I access my qooxdoo application via
http://application... evereything looks fine. But when I access it via https
I get access denied msgs from the RPC backend.

I use the same domain and also https for the rpc service url.

What can that be the reason for that?

Can you help one more time?

Philipp


Andreas Junghans wrote:

>
> Hi Philipp,
>
> Am 23.07.2008 um 12:02 schrieb Philipp Wabinski:
>
>> you were right! Thanks for your answer!
>>
>> I have set the cross domain to true:
>>
>> this.rpc.setCrossDomain(false);
>>
>> I set it to false and the data was send via POST :) !
>>
>> I use qooxdoo since 0.6.3 and I`m really sure that cross domain hast  
>> to be
>> set to true to make an async call in older Versions.
>
> This would be a very odd bug - I don't recall anything like that, but  
> I might be wrong.
>
>> Do you know since which version it doesn`t has to be set anymore to  
>> true?
>
> Sorry, I don't know about any such bug.
>
> Regards,
>
>    Andreas
>
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's
> challenge
> Build the coolest Linux based applications with Moblin SDK & win great
> prizes
> Grand prize is a trip for two to an Open Source event anywhere in the
> world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> qooxdoo-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
>
>

--
View this message in context: http://www.nabble.com/-SOLVED--Send-async-rpc-via-POST--tp18606916p18609314.html
Sent from the qooxdoo-devel mailing list archive at Nabble.com.


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: Send async rpc via POST?

Philipp Wabinski

Hi,

I testet a little more.

When I use a url like this https://192.168.2.4/project/index.html for my
qooxdoo application and https://192.168.2.4´/project/rpc_services/ as rpc
path, I get an access denied msg.

When I test it with the same qooxdoo source code (crossDomain(false)) on my
live system with this urls
https://domain.de/project/index.html and
https://domain.de/project/rpc_services as rpc path it works without an acces
denied error.

Philipp


Philipp Wabinski wrote:

>
> Hi Andreas,
>
> I have another error right now. When I access my qooxdoo application via
> http://application... evereything looks fine. But when I access it via
> https I get access denied msgs from the RPC backend.
>
> I use the same domain and also https for the rpc service url.
>
> What can that be the reason for that?
>
> Can you help one more time?
>
> Philipp
>
>
> Andreas Junghans wrote:
>>
>> Hi Philipp,
>>
>> Am 23.07.2008 um 12:02 schrieb Philipp Wabinski:
>>
>>> you were right! Thanks for your answer!
>>>
>>> I have set the cross domain to true:
>>>
>>> this.rpc.setCrossDomain(false);
>>>
>>> I set it to false and the data was send via POST :) !
>>>
>>> I use qooxdoo since 0.6.3 and I`m really sure that cross domain hast  
>>> to be
>>> set to true to make an async call in older Versions.
>>
>> This would be a very odd bug - I don't recall anything like that, but  
>> I might be wrong.
>>
>>> Do you know since which version it doesn`t has to be set anymore to  
>>> true?
>>
>> Sorry, I don't know about any such bug.
>>
>> Regards,
>>
>>    Andreas
>>
>>
>> -------------------------------------------------------------------------
>> This SF.Net email is sponsored by the Moblin Your Move Developer's
>> challenge
>> Build the coolest Linux based applications with Moblin SDK & win great
>> prizes
>> Grand prize is a trip for two to an Open Source event anywhere in the
>> world
>> http://moblin-contest.org/redirect.php?banner_id=100&url=/
>> _______________________________________________
>> qooxdoo-devel mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
>>
>>
>
>

--
View this message in context: http://www.nabble.com/-SOLVED--Send-async-rpc-via-POST--tp18606916p18609776.html
Sent from the qooxdoo-devel mailing list archive at Nabble.com.


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: Send async rpc via POST?

Andreas Junghans
In reply to this post by Philipp Wabinski
Hi Philipp,

Am 23.07.2008 um 14:09 schrieb Philipp Wabinski:

> I have another error right now. When I access my qooxdoo application  
> via
> http://application... evereything looks fine. But when I access it  
> via https
> I get access denied msgs from the RPC backend.
>
> I use the same domain and also https for the rpc service url.
>
> What can that be the reason for that?

As long as you use the same protocol (HTTP or HTTPS) for the HTML page  
and the RPC, it's supposed to work. If it does not, I guess there's  
either a problem in the PHP backend or in your server configuration.  
Maybe you are redirecting HTTPS requests to a plain HTTP server?

Derrell, can you take a look? I'm not familiar enough with the PHP  
backend to be of much help here.

Regards,

   Andreas


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: Send async rpc via POST?

Andreas Junghans
In reply to this post by Philipp Wabinski
Hi Philipp,

Am 23.07.2008 um 14:36 schrieb Philipp Wabinski:

> When I use a url like this https://192.168.2.4/project/index.html 
> for my
> qooxdoo application and https://192.168.2.4´/project/rpc_services/ 
> as rpc
> path, I get an access denied msg.
>
> When I test it with the same qooxdoo source code  
> (crossDomain(false)) on my
> live system with this urls
> https://domain.de/project/index.html and
> https://domain.de/project/rpc_services as rpc path it works without  
> an acces
> denied error.

Your browser is trying to protect you :-)  You must have a trusted  
certificate (or a certificate sigend by a trusted CA) for  
"192.168.2.4". Otherwise, at least Firefox won't let you get to the  
page by default. So it looks like this is purely a configuration/
testing issue, and the PHP backend is working fine.

Regards,

   Andreas


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: Send async rpc via POST?

Derrell Lipman
In reply to this post by Andreas Junghans
On Wed, Jul 23, 2008 at 8:43 AM, Andreas Junghans <[hidden email]> wrote:
Hi Philipp,

Am 23.07.2008 um 14:09 schrieb Philipp Wabinski:


I have another error right now. When I access my qooxdoo application via
http://application... evereything looks fine. But when I access it via https
I get access denied msgs from the RPC backend.

I use the same domain and also https for the rpc service url.

What can that be the reason for that?

As long as you use the same protocol (HTTP or HTTPS) for the HTML page and the RPC, it's supposed to work. If it does not, I guess there's either a problem in the PHP backend or in your server configuration. Maybe you are redirecting HTTPS requests to a plain HTTP server?

Derrell, can you take a look? I'm not familiar enough with the PHP backend to be of much help here.

With the default accessibility configuration ("domain"), the PHP backend confirms that the request URI domain matches the referer domain (including protocol).  As long as both the original page and the services URI use https or both don't use https, the backend should handle it fine.

The only gotcha may be if you're manually specifying a port number.  We attempt to match that, but if you're using other than port 80 for http or port 443 for https, that code path is not well tested and may deny access when it should be allowed.

Derrell


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: Send async rpc via POST?

Philipp Wabinski
In reply to this post by Andreas Junghans

Thanks again,

yes I see its a configuration problem on my local server.

The $_SERVER["SSL_PROTOCOL"] var is empty and then the php backend produces
that error.

I will look how to fix that.

Philipp


Andreas Junghans wrote:

>
> Hi Philipp,
>
> Am 23.07.2008 um 14:36 schrieb Philipp Wabinski:
>
>> When I use a url like this https://192.168.2.4/project/index.html 
>> for my
>> qooxdoo application and https://192.168.2.4´/project/rpc_services/ 
>> as rpc
>> path, I get an access denied msg.
>>
>> When I test it with the same qooxdoo source code  
>> (crossDomain(false)) on my
>> live system with this urls
>> https://domain.de/project/index.html and
>> https://domain.de/project/rpc_services as rpc path it works without  
>> an acces
>> denied error.
>
> Your browser is trying to protect you :-)  You must have a trusted  
> certificate (or a certificate sigend by a trusted CA) for  
> "192.168.2.4". Otherwise, at least Firefox won't let you get to the  
> page by default. So it looks like this is purely a configuration/
> testing issue, and the PHP backend is working fine.
>
> Regards,
>
>    Andreas
>
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's
> challenge
> Build the coolest Linux based applications with Moblin SDK & win great
> prizes
> Grand prize is a trip for two to an Open Source event anywhere in the
> world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> qooxdoo-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
>
>

--
View this message in context: http://www.nabble.com/-SOLVED--Send-async-rpc-via-POST--tp18606916p18610859.html
Sent from the qooxdoo-devel mailing list archive at Nabble.com.


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel