Results 1 to 4 of 4

Thread: [SOLVED] Does POST method through proxy work?

  1. #1
    ab5602 is offline Project Contributor
    Join Date
    Nov 2007
    Location
    Detroit, MI
    Posts
    67
    Rep Power
    7

    Question [SOLVED] Does POST method through proxy work?

    I'm trying to get an HTML POST to an external page to work via the built-in Zimlet proxy service, but I've so far have been unable to get the proxy to pass the POST variables through...

    GET requests work :
    Code:
     
     var request = new AjxRpcRequest("zimlet"); 
     var info_url = "http://test.com?key=value";
     var url = ZmZimletBase.PROXY + AjxStringUtil.urlEncode(info_url);
     request.invoke(null, url, null, new AjxCallback(this, my.callback, div), true);
    Inserting headers works :
    Code:
     
     var request = new AjxRpcRequest("zimlet"); 
     var reqHeader = {"Content-Type":"application/x-www-form-urlencoded"};
     var info_url = "http://test.com";
     var url = ZmZimletBase.PROXY + AjxStringUtil.urlEncode(info_url);
     request.invoke(null, url, reqHeader, new AjxCallback(this, my.callback, div), true);
    But I can't seem to get HTML POSTs working? :
    Code:
     
     var request = new AjxRpcRequest("zimlet"); 
     var reqHeader = {"Content-Type":"application/x-www-form-urlencoded"};
     var reqParam = AjxStringUtil.urlEncode("a=b");
     var info_url = "http://test.com";
     var url = ZmZimletBase.PROXY + AjxStringUtil.urlEncode(info_url);
     request.invoke(reqParam, url, reqHeader, new AjxCallback(this, my.callback, div), true);
    The POST variables just never show up at the server.. Does anyone know if the Proxy service allows HTTP POSTs or am I doing something wrong here?

    Thanks!
    -Rob
    Last edited by ab5602; 09-15-2008 at 12:16 PM.

  2. #2
    ab5602 is offline Project Contributor
    Join Date
    Nov 2007
    Location
    Detroit, MI
    Posts
    67
    Rep Power
    7

    Default

    Figured it Out

    I found some documentations regarding the AjxRpcRequest.invoke() method in the source code:

    Code:
     * Sends this request to the target URL. If there is a callback, the request is
     * performed asynchronously.
     *
     * @param {String} requestStr HTTP request string/document
     * @param {String} serverUrl request target
     * @param {Array} requestHeaders Array of HTTP request headers (optional)
     * @param {AjxCallback} callback callback for asynchronous requests. This callback
     *              will be invoked when the requests completes. It will be passed the same
     *              values as when this method is invoked synchronously (see the return values
     *              below) with the exception that if the call times out (see timeout param
     *              below), then the object passed to the callback will be the same as in the
     *              error case with the exception that the status will be set to
     *              <code>AjxRpcRequest.TIMEDOUT</code>
     * @param {Boolean} useGet if true use get method, else use post. If ommitted
     *              defaults to post
     * @param {Int} timeout Timeout (in milliseconds) after which the request is
     *              cancelled (optional)
    So, changing the "useGet" to "false" obviously solved my problem and the following code works just great, even through the proxy!

    Code:
     
    var request = new AjxRpcRequest("zimlet"); 
     var reqHeader = {"Content-Type":"application/x-www-form-urlencoded"};
     var reqParam = AjxStringUtil.urlEncode("a=b");
     var info_url = "http://test.com";
     var url = ZmZimletBase.PROXY + AjxStringUtil.urlEncode(info_url);
     request.invoke(reqParam, url, reqHeader, new AjxCallback(this, my.callback, div), false);

  3. #3
    Join Date
    Jun 2009
    Location
    India
    Posts
    12
    Rep Power
    6

    Default

    Hello ab5602,
    I am new to zimlet. I am trying the same Ajax call in JavaScript but I am getting 403 forbidden error everytime in Ajax call. I have allowed "*" domain in config_template.xml file but still having same problem. Can you have any idea rearding that issue ?

    Thanx in Advance.

  4. #4
    ab5602 is offline Project Contributor
    Join Date
    Nov 2007
    Location
    Detroit, MI
    Posts
    67
    Rep Power
    7

    Default

    Hello,

    If you're using your Zimlet in the /_dev/ directory, the allowedDomains settings in your XML template file won't work, as that only gets set when you actually deploy your zimlet. Try doing the following from the command line:

    Code:
    zmprov mc <COS> +zimbraProxyAllowedDomains *
    ..where <COS> is a Zimbra Class Of Service identifier.

    Otherwise, if you're trying to open a URL on the Zimbra server itself, it's possible that Zimbra is simply telling you that you are trying to access something that you should not be able to access with your credentials, regardless of the Zimlet proxy domains allowed.

    Hope this helps.

    -Rob

Thread Information

Users Browsing this Thread

There are currently 2 users browsing this thread. (0 members and 2 guests)

Similar Threads

  1. Replies: 13
    Last Post: 01-28-2009, 01:30 AM
  2. zmtlsctl command not completing successfully
    By relay23 in forum Administrators
    Replies: 21
    Last Post: 07-10-2008, 12:07 AM
  3. Replies: 4
    Last Post: 05-08-2008, 09:12 AM
  4. No response from Jetty on clean 5.02 OS install
    By cniknet in forum Administrators
    Replies: 0
    Last Post: 02-16-2008, 12:17 PM
  5. Replies: 1
    Last Post: 01-02-2008, 09:31 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •