OpenSocial / spec

OpenSocial Specification #social
http://opensocial.org/
Apache License 2.0
106 stars 11 forks source link

gadgets.io.makeRequest with POST does not POST data to external server #16

Closed mmarum-sugarcrm closed 11 years ago

mmarum-sugarcrm commented 11 years ago

Original author: api.kurrik%google.com@gtempaccount.com (February 08, 2008 21:32:58)

Description of the problem ========================== Using gadgets.io.makeRequest with gadgets.io.RequestParameters.METHOD = gadgets.io.MethodType.POST does not actually pass POST data to the external servers.

What steps will reproduce the problem? ======================================

  1. Install gadget at http://graargh.returnstrue.com/bugs/bug_postdata.xml in Orkut
  2. View Gadget - it makes a POST request to http://graargh.returnstrue.com/bugs/bug_postdata.php

What is the expected output? ============================ The gadget prints {"POST":{"data1":"test","data2":"1234566"}}

What is the actual output? ========================== The gadget prints {"POST":[]}

Which container are you using? ============================== Orkut

Additional Information

Here is the POST request sent to gmodules

POST /46/o/ig/proxy?url=http%3A%2F%2Fgraargh.returnstrue.com%2Fbugs%2Fbugpostdata.php&output=js HTTP/1.1 Host: 4.o.gmodules.com User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11 Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,/_;q=0.5 Accept-Language: en-us,en;q=0.5 Accept-Encoding: gzip,deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive: 300 Proxy-Connection: keep-alive Content-Type: application/x-www-form-urlencoded Referer: http://4.o.gmodules.com/46/o/ig/ifr?url=http://graargh.returnstrue.com/bugs/bug_postdata.xml&parent=http://sandbox.orkut.com/46/o/ig/files/container/ifpc_relay.html&lang=en-US&country=US&synd=orkut&view=canvas&mid=4&h=600 Content-Length: 39 Pragma: no-cache Cache-Control: no-cache postData=data1%3Dtest%26data2%3D1234566

Please use labels and text to provide additional information.

Original issue: http://code.google.com/p/opensocial-resources/issues/detail?id=2

mmarum-sugarcrm commented 11 years ago

From api.kurrik%google.com@gtempaccount.com on February 08, 2008 22:49:07 According to: http://www.bradino.com/php/empty-post-array/

This bug may be caused by the application/x-www-form-urlencoded content type header not being set. You can get access to the raw post data by using:

$data = file_get_contents('php://input');

mmarum-sugarcrm commented 11 years ago

From lrajl...@gmail.com on February 12, 2008 00:32:36 The function makeRequest in the javascript file ifr?url=... In the function, there is an if statement

if (params.postData)

which is undefined. This should be params.POST_DATA to be consistent with the enums specified for the optional params. When I pass params["postData"], it does the right thing in the function but I still don't see the post data, trying php://input also yields nothing.

mmarum-sugarcrm commented 11 years ago

From api.kurrik%google.com@gtempaccount.com on February 20, 2008 00:43:07 The correct Content-Type header is now being passed by default.

mmarum-sugarcrm commented 11 years ago

From PravinCl...@gmail.com on February 20, 2008 16:53:12 I tried today and it was posting information correctly to my server.

mmarum-sugarcrm commented 11 years ago

From alexande...@gmail.com on February 20, 2008 22:52:57 This is still not working for me. I think that closing this bug was premature.

mmarum-sugarcrm commented 11 years ago

From alexande...@gmail.com on February 20, 2008 23:13:39 Yes, definitely not fixed. The data is available from the raw request body but not as a parameter. I'm using Java on Tomcat 5.5.23.

mmarum-sugarcrm commented 11 years ago

From api.kurrik%google.com@gtempaccount.com on February 21, 2008 04:14:16 alexander, can you post some example code that you're using to make the request and process it server-side? I'm seeing this functioning on my servers.

mmarum-sugarcrm commented 11 years ago

From PUdayaSh...@gmail.com on February 21, 2008 07:26:38 hey even i am facing the same issue

mmarum-sugarcrm commented 11 years ago

From alexande...@gmail.com on February 21, 2008 14:34:31 Here's my client-side code. There's no server-side code to give - it's just that the HttpServletRequest instance in the servlet doesn't contain "foo" in it's parameter map (e.g. request.getParameterMap()), but does contain the string "foo=bar" on the input stream (post data). I could be wrong, but I think that Tomcat should include the POST parameters in the parameter map... Perhaps it's because I'm also getting parameters in the query string? I'm using a signed POST makeRequest.

function doMakeRequest() { var data = {"foo": "bar"}

var params = {} params[gadgets.io.RequestParameters.METHOD] = gadgets.io.MethodType.POST; params[gadgets.io.RequestParameters.POST_DATA] = gadgets.io.encodeValues(data); var url = "http://24.61.42.19:8080/typeracer-0.7/";

makeCacheControlledSignedRequest(url, requestTyperacerIframeCallback, params, 0); }

function makeCacheControlledSignedRequest(url, callback, params, refreshInterval) { var ts = new Date().getTime(); var sep = "?"; if (refreshInterval && refreshInterval > 0) { ts = Math.floor(ts / (refreshInterval * 1000)); } if (url.indexOf("?") > -1) { sep = "&"; } url = [ url, sep, "nocache=", ts ].join("");

params = params || {} params[gadgets.io.RequestParameters.AUTHORIZATION] = gadgets.io.AuthorizationType.SIGNED; gadgets.io.makeRequest(url, callback, params); }

mmarum-sugarcrm commented 11 years ago

From muralidh...@gmail.com on February 22, 2008 10:07:43 POST data example as specified in the bug is failing for me as well. I just took the xml and and changed the url to hit my server served by Rails and i don't get any params passed on the controller side. This issue should remain open.

mmarum-sugarcrm commented 11 years ago

From api.kurrik%google.com@gtempaccount.com on February 22, 2008 18:48:23 There seems to have been a regression on this issue.

mmarum-sugarcrm commented 11 years ago

From alexande...@gmail.com on February 23, 2008 21:12:14 This is now fixed with the Feb 22 push.

mmarum-sugarcrm commented 11 years ago

From pedr...@gmail.com on March 25, 2008 22:49:06 It seems I can't really change the Content-Type in the header. I would like to be Content-Type: application/x-www-form-urlencoded; charset=utf-8

instead of just: Content-Type: application/x-www-form-urlencoded

any ideas?

mmarum-sugarcrm commented 11 years ago

From api.kurrik%google.com@gtempaccount.com on March 26, 2008 01:00:28 Hi Pedro,

That's worth filing a new issue for. Can you make a new entry in this tracker?

Thanks, ~Arne

mmarum-sugarcrm commented 11 years ago

From pedr...@gmail.com on March 26, 2008 01:28:33 Hi Arne, thanks for replying. I'm still trying to figure it out the problem.

Right now, I can get around setting the default encoding for my web server. When I fulyl understand the issue, I'll create it.

cheers, Pedro

mmarum-sugarcrm commented 11 years ago

From pedr...@gmail.com on March 26, 2008 14:50:28 I think my problem is that the orkut's servlet is not posting url-encoded data. Any one knows about it?

mmarum-sugarcrm commented 11 years ago

From npel...@gmail.com on December 21, 2008 11:08:23 This issue, or one similar, definitely still persists in the current 0.8 version of the sandbox on iGoogle.

I am calling makeRequest like so:

    var params = {};
    params[gadgets.io.RequestParameters.METHOD_TYPE] = gadgets.io.MethodType.POST;
    params["httpMethod"] = gadgets.io.MethodType.POST;
    var postData = gadgets.io.encodeValues({text:words});
    gadgets.io.makeRequest(url, callback, params);

and the resulting HTTP request being made to the sandbox is:

http://115.ig.sandbox.gmodules.com/gadgets/makeRequest?refresh=3600&url=http%3A%2F%2Fwww.wordcalc.com%2Findex.php&httpMethod=GET&headers=&postData=&authz=&st=&contentType=TEXT&numEntries=3&getSummaries=false&signOwner=true&signViewer=true&gadget=XXX.xml&container=ig&bypassSpecCache=1

NOTE: the httpMethod being passed to gadgets/makeRequest is GET.

If I modify this to POST, then a POST is actually performed on the server.

Any ideas when this will be fixed?

Cheers, Nick