Zimbra offers Open Source email server software and shared calendar for Linux and the Mac
 
Go Back   Zimbra - Forums > Zimbra Collaboration Suite > Zimlets

Welcome to the Zimbra - Forums!
Welcome, if you would like to post a comment please register. We also encourage you to explore all things Zimbra with our team and members of the community.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 09-15-2008, 01:09 PM
Project Contributor
 
Posts: 63
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 01:16 PM.
Reply With Quote
  #2 (permalink)  
Old 09-17-2008, 01:03 PM
Project Contributor
 
Posts: 63
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);
Reply With Quote
  #3 (permalink)  
Old 07-01-2009, 01:47 AM
Member
 
Posts: 12
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.
Reply With Quote
  #4 (permalink)  
Old 07-01-2009, 05:33 AM
Project Contributor
 
Posts: 63
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
Reply With Quote
Reply


Thread Tools
Display Modes


Similar Threads

Why Join?

Registering let's you ask questions, makes it easier to search, displays any files attached to posts, and notifies you about replies.

Zimbrablog.com




 

Search Engine Optimization by vBSEO 3.1.0