[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] /srv/bzr/gnash/trunk r12244: also send the data for GET a
From: |
Rob Savoye |
Subject: |
[Gnash-commit] /srv/bzr/gnash/trunk r12244: also send the data for GET and POST requests. Fix getURL(POST), improve testcase. |
Date: |
Fri, 11 Jun 2010 19:10:28 -0600 |
User-agent: |
Bazaar (2.0.3) |
------------------------------------------------------------
revno: 12244
committer: Rob Savoye <address@hidden>
branch nick: trunk
timestamp: Fri 2010-06-11 19:10:28 -0600
message:
also send the data for GET and POST requests. Fix getURL(POST), improve
testcase.
modified:
libcore/movie_root.cpp
plugin/npapi/geturl.as
plugin/npapi/plugin.cpp
plugin/npapi/pluginScriptObject.cpp
=== modified file 'libcore/movie_root.cpp'
--- a/libcore/movie_root.cpp 2010-06-11 13:10:12 +0000
+++ b/libcore/movie_root.cpp 2010-06-12 01:10:28 +0000
@@ -2108,44 +2108,42 @@
}
/// This is when there is a hosting application.
- std::ostringstream request;
- std::string querystring;
+ std::vector<as_value> fnargs;
+ // The first argument we push on the stack is the URL
+ fnargs.push_back(as_value(urlstr));
+
switch (method) {
case MovieClip::METHOD_POST:
- request << "POST " << target << ":" <<
- data << "$" << urlstr << std::endl;
- break;
-
- // METHOD_GET and METHOD_NONE are the same, except that
- // for METHOD_GET we append the variables to the query
- // string.
+ fnargs.push_back(as_value("POST"));
+ break;
case MovieClip::METHOD_GET:
- // Append vars to URL query string
- if (urlstr.find("?") == std::string::npos) {
- querystring = "?";
- }
- else querystring = "&";
- querystring.append(data);
-
+ fnargs.push_back(as_value("GET"));
+ break;
case MovieClip::METHOD_NONE:
- // use the original url, non parsed (the browser will know
- // better how to resolve relative urls and handle
- // javascript)
- request << "GET " << target << ":" << urlstr << std::endl;
- break;
- }
-
- std::string requestString = request.str();
+ default:
+ fnargs.push_back(as_value("GET"));
+ break;
+ }
+
+ // The third argument is the target, which is something like _blank
+ // or _self.
+ if (!target.empty()) {
+ fnargs.push_back(as_value(target));
+ }
+ // Add any data as the optional 4th argument
+ if (!data.empty()) {
+ // We have to write a value here so the data field is the fourth
+ if (target.empty()) {
+ fnargs.push_back(as_value("none"));
+ }
+ fnargs.push_back(as_value(data));
+ }
+
// TODO: should mutex-protect this ?
// NOTE: we are assuming the hostfd is set in blocking mode here..
log_debug(_("Attempt to write geturl requests fd #%d"), _hostfd);
- std::vector<as_value> fnargs;
- fnargs.push_back(as_value(urlstr));
- if (!target.empty()) {
- fnargs.push_back(as_value(target));
- }
std::string msg = ExternalInterface::makeInvoke("getURL", fnargs);
size_t ret = ExternalInterface::writeBrowser(_hostfd, msg);
@@ -2153,12 +2151,6 @@
log_error(_("Could only write %d bytes to fd #%d"),
ret, _hostfd);
}
-
- // The request string ends with newline, and we don't want to log that
-#if 0
- requestString.resize(requestString.size() - 1);
- log_debug(_("Sent request '%s' to host fd %d"), requestString, _hostfd);
-#endif
}
void
=== modified file 'plugin/npapi/geturl.as'
--- a/plugin/npapi/geturl.as 2010-05-29 16:06:24 +0000
+++ b/plugin/npapi/geturl.as 2010-06-12 01:10:28 +0000
@@ -1,1 +1,23 @@
+/*
+getURL(url [, window [, "variables"]])
+
+Parameters
+ _self specifies the current frame in the current window.
+ _blank specifies a new window.
+ _parent specifies the parent of the current frame.
+ _top specifies the top-level frame in the current window.
+
+variables A GET or POST method for sending variables. If there are no
+variables, omit this parameter. The GET method appends the variables to
+the end of the URL, and is used for small numbers of variables. The POST
+method sends the variables in a separate HTTP header and is used for
+sending long strings of variables.
+
+*/
+
+var firstname = "Foo";
+var lastname = "Bar";
+var age = 100;
+getURL("http://www.gnashdev.org", '_blank', 'POST');
+
getURL("http://www.gnashdev.org");
=== modified file 'plugin/npapi/plugin.cpp'
--- a/plugin/npapi/plugin.cpp 2010-06-04 06:29:59 +0000
+++ b/plugin/npapi/plugin.cpp 2010-06-12 01:10:28 +0000
@@ -725,25 +725,58 @@
ExternalInterface::invoke_t *invoke = ExternalInterface::parseInvoke(buf);
+ // The invoke message is also used for getURL. In this case there are 4
+ // possible arguments.
if (invoke) {
if (invoke->name == "getURL") {
// gnash::log_debug("Got a getURL() request: %",
invoke->args[0].get());
- std::string url =
NPStringToString(NPVARIANT_TO_STRING(invoke->args[0].get()));
+ // The first argument is the URL string.
+ std::string url = NPStringToString(NPVARIANT_TO_STRING(
+ invoke->args[0].get()));
+ // The second is the the method, namely GET or POST.
+ std::string op = NPStringToString(NPVARIANT_TO_STRING(
+ invoke->args[1].get()));
+ // The third is the optional target, which is something like
+ // _blank or _self.
std::string target;
- if (invoke->args.size() == 2) {
- target =
NPStringToString(NPVARIANT_TO_STRING(invoke->args[1].get()));
+ // The fourth is the optional data. If there is data, the target
+ // field is always set so this argument is on the correct index.
+ // No target is "none".
+ std::string data;
+ if (invoke->args.size() >= 3) {
+ target = NPStringToString(NPVARIANT_TO_STRING(
+ invoke->args[2].get()));
+ if (target == "NONE") {
+ target.clear();
+ }
+ }
+ if (invoke->args.size() == 4) {
+ data = NPStringToString(NPVARIANT_TO_STRING(
+ invoke->args[3].get()));
+ }
+ if (op == "GET") {
+ gnash::log_debug("Asked to getURL '%s' in target %s", url,
+ target);
+ NPN_GetURL(_instance, url.c_str(), target.c_str());
+ } else if (op == "POST") {
+ gnash::log_debug("Asked to postURL '%s' this data %s", url,
+ data);
+ NPN_PostURL(_instance, url.c_str(), target.c_str(),
data.size(),
+ data.c_str(), false);
+ return true;
}
- gnash::log_debug("Asked to getURL '%s' in target %s", url, target);
- NPN_GetURL(_instance, url.c_str(), target.c_str());
return true;
} else if (invoke->name == "fsCommand") {
- std::string command =
NPStringToString(NPVARIANT_TO_STRING(invoke->args[0].get()));
- std::string arg =
NPStringToString(NPVARIANT_TO_STRING(invoke->args[1].get()));
+ std::string command = NPStringToString(NPVARIANT_TO_STRING(
+ invoke->args[0].get()));
+ std::string arg = NPStringToString(NPVARIANT_TO_STRING(
+ invoke->args[1].get()));
std::string name = _name;
std::stringstream jsurl;
- jsurl << "javascript:" << name << "_DoFSCommand('" << command <<
"','" << arg <<"')";
+ jsurl << "javascript:" << name << "_DoFSCommand('" << command
+ << "','" << arg <<"')";
// TODO: check if _self is a good target for this
static const char* tgt = "_self";
@@ -753,36 +786,6 @@
NPN_GetURL(_instance, jsurl.str().c_str(), tgt);
return true;
-#if 0
- } else if ( ! strncmp(buf, "POST ", 5)) {
- char* target = buf + 5;
- if (! *target) return false;
-
- char* postdata = target;
- while (*postdata && *postdata != ':') ++postdata;
- if ( *postdata ) {
- *postdata='\0';
- ++postdata;
- } else {
- gnash::log_error("No colon found after getURL postdata
string");
- return false;
- }
-
- char* url = postdata;
- while (*url && *url != '$') ++url;
- if (*url) {
- *url='\0';
- ++url;
- } else {
- gnash::log_error("No $ character found after getURL target
string");
- return false;
- }
-
- NPN_PostURL(_instance, url, target, std::strlen(postdata),
- postdata, false);
-
- return true;
-#endif
}
} else {
gnash::log_error("Unknown player request: " + std::string(buf));
@@ -1201,11 +1204,11 @@
}
#else
void
-processLog_debug(const boost::format& fmt)
+processLog_debug(const boost::format& /* fmt */)
{ /* do nothing */ }
void
-processLog_trace(const boost::format& fmt)
+processLog_trace(const boost::format& /* fmt */)
{ /* do nothing */ }
#endif
=== modified file 'plugin/npapi/pluginScriptObject.cpp'
--- a/plugin/npapi/pluginScriptObject.cpp 2010-06-02 14:18:20 +0000
+++ b/plugin/npapi/pluginScriptObject.cpp 2010-06-12 01:10:28 +0000
@@ -827,7 +827,7 @@
// Send a Quit message to the player before closing the pipe.
std::vector<std::string> args;
std::string str = ExternalInterface::makeInvoke("Quit", args);
- size_t ret = writePlayer(fd, str);
+ size_t ret = writePlayer(fd, str);
::shutdown(fd, SHUT_RDWR);
::close(fd);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] /srv/bzr/gnash/trunk r12244: also send the data for GET and POST requests. Fix getURL(POST), improve testcase.,
Rob Savoye <=