1. #1
    Ext User
    Join Date
    Mar 2010
    Posts
    31
    Vote Rating
    0
    ykoehler is on a distinguished road

      0  

    Post Ext.Direct call sending an HTTP OPTIONS cmd

    Ext.Direct call sending an HTTP OPTIONS cmd


    I am trying to use Ext.Direct with a remote site. I defined my API like this:

    Code:
     
    Ext.ns('MSMWeb');
    MSMWeb.API = {
      "url":"http://192.168.1.2/ext/direct/router",
      "type":"remoting",
      "actions":{
        "Interfaces":[
          {"name":"load","len":0},
          {"name":"setIPv4","len":1,"formHandler":true}
        ]
      },
      "namespace":"MSMWeb"
    };
    If I attempt to call my method setIPv4 I see inside Firebug an

    OPTIONS http://192.168.1.2/ext/direct/router

    But if I replace the url with a local value such as

    "url":"router.php",

    and I call it, I then see an HTTP POST

    POST router.php

    Can someone explain this behavior and how I can actually get a POST with a remote URL using Ext.Direct?

    --
    Yannick Koehler

  2. #2
    Sencha User
    Join Date
    Sep 2007
    Location
    Tulsa, Oklahoma
    Posts
    178
    Vote Rating
    1
    ckr is on a distinguished road

      0  

    Default


    Code:
     "url":"http://192.168.1.2/ext/direct/router",
    I believe should be
    Code:
     "url":"http://192.168.1.2/ext/direct/router/router.php",
    If that is where your router is located. It doesn't know to use router.php as the router. You router process could be named anything.
    Thanks!
    Chuck

  3. #3
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    16,833
    Vote Rating
    609
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  4. #4
    Ext User
    Join Date
    Mar 2010
    Posts
    31
    Vote Rating
    0
    ykoehler is on a distinguished road

      0  

    Default


    Quote Originally Posted by evant View Post
    Actually, I can...

    Using that document about same origin policy, I've altered my server to answered positively to the HTTP OPTIONS and the browser did follow with an HTTP POST.

    So I did found how to solve this case, my next problem thought is that my server reply and the browser do not see the "data" portion of the reply but do see the header.

    Even wireshark see the data and things seems to be valid yet the browser firebug and extjs do not seems to like it.

    Code:
    POST /ext/direct/router HTTP/1.1 
    Host: 192.168.1.2 
    User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2) Gecko/20100304 Gentoo Firefox/3.6 FirePHP/0.4 
    Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 
    Accept-Language: fr-ca,fr;q=0.8,en-us;q=0.5,en;q=0.3 
    Accept-Encoding: gzip,deflate 
    Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 
    Keep-Alive: 115 
    Connection: keep-alive 
    X-Requested-With: XMLHttpRequest 
    Content-Type: application/x-www-form-urlencoded; charset=UTF-8 
    Referer: http://127.0.0.1/ 
    Content-Length: 113 
    Origin: http://127.0.0.1 
    Pragma: no-cache 
    Cache-Control: no-cache 
     
    extTID=6&extAction=Interfaces&extMethod=setIPv4&extType=rpc&extUpload=false&ipaddress=&ipnetmask=&gatewayaddress=
    Code:
    HTTP/1.1 200 OK 
    Server: Myserver 
    Date: Mon, 08 Mar 2010 15:41:41 GMT 
    Connection: close 
    Pragma: no-cache 
    Cache-Control: no-cache 
    Content-Type: text/html 
    Content-Length: 91 
     
    {"type":"rpc","tid":"6","action":"Interfaces","method":"setIPv4","result":{"success":true}}
    I fail to see what firefox or extjs do not like, the header is properly separated by a \r\n the data content of the reply is valid JSON, yet when I look inside Firebug it says that it received 91 B of size in the body response yet in the "Response" tab there is nothing, it's empty.

    Any idea or suggestion?

    --
    Yannick Koehler

  5. #5
    Sencha User
    Join Date
    May 2010
    Location
    London, UK
    Posts
    21
    Vote Rating
    0
    meercat is on a distinguished road

      0  

    Default


    Very late to a thread again, but in case it help someone else in the future:

    I was doing precisely this - cross domain requests to am ExtDirect server.
    What I found I had to do was that the browser first sends an OPTIONS call, which I reply to in order to say that I'm happy to be called from a different origin, so the following headers but no body

    Code:
      Access-Control-Allow-Origin: *
      Access-Control-Allow-Methods: POST, GET , OPTIONS
      Access-Control-Allow-Headers: X-Requested-With, Content-Type
    and then for each subsequent request (GET, POST etc) I have to again say that I'm happy to allow a different origin by adding the following HTTP header to the response

    Code:
      Access-Control-Allow-Origin: *
    and then the browser will happily pass the result thru to the javascript code.

    In this case I'm allowing absolutely any different origin ("*") but YMMV

  6. #6
    Sencha User
    Join Date
    Feb 2012
    Location
    Georgia, Tbilisi
    Posts
    4
    Vote Rating
    0
    arboshiki is on a distinguished road

      0  

    Default Cross domain problem

    Cross domain problem


    Hello everyone,
    I have the same problem about cross domain I am using sencha touch and using ext direct I want to access methods in different domain. How can I do this? Can you provide us a little but main code?

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi