summaryrefslogtreecommitdiff
path: root/scene/main
diff options
context:
space:
mode:
Diffstat (limited to 'scene/main')
-rw-r--r--scene/main/http_request.cpp12
-rw-r--r--scene/main/http_request.h4
-rw-r--r--scene/main/node.cpp10
-rw-r--r--scene/main/scene_main_loop.cpp8
4 files changed, 18 insertions, 16 deletions
diff --git a/scene/main/http_request.cpp b/scene/main/http_request.cpp
index 9b79af32bf..c713b5e4dc 100644
--- a/scene/main/http_request.cpp
+++ b/scene/main/http_request.cpp
@@ -96,7 +96,7 @@ Error HTTPRequest::_parse_url(const String& p_url) {
return OK;
}
-Error HTTPRequest::request(const String& p_url, const Vector<String>& p_custom_headers, bool p_ssl_validate_domain) {
+Error HTTPRequest::request(const String& p_url, const Vector<String>& p_custom_headers, bool p_ssl_validate_domain, HTTPClient::Method p_method, const String& p_request_data) {
ERR_FAIL_COND_V(!is_inside_tree(),ERR_UNCONFIGURED);
if ( requesting ) {
@@ -104,6 +104,8 @@ Error HTTPRequest::request(const String& p_url, const Vector<String>& p_custom_h
ERR_FAIL_V(ERR_BUSY);
}
+ method=p_method;
+
Error err = _parse_url(p_url);
if (err)
return err;
@@ -114,6 +116,8 @@ Error HTTPRequest::request(const String& p_url, const Vector<String>& p_custom_h
bool has_accept=false;
headers=p_custom_headers;
+ request_data = p_request_data;
+
for(int i=0;i<headers.size();i++) {
if (headers[i].findn("user-agent:")==0)
@@ -281,7 +285,7 @@ bool HTTPRequest::_update_connection() {
switch( client->get_status() ) {
case HTTPClient::STATUS_DISCONNECTED: {
call_deferred("_request_done",RESULT_CANT_CONNECT,0,StringArray(),ByteArray());
- return true; //end it, since it's doing something
+ return true; //end it, since it's doing something
} break;
case HTTPClient::STATUS_RESOLVING: {
client->poll();
@@ -334,7 +338,7 @@ bool HTTPRequest::_update_connection() {
} else {
//did not request yet, do request
- Error err = client->request(HTTPClient::METHOD_GET,request_string,headers);
+ Error err = client->request(method,request_string,headers,request_data);
if (err!=OK) {
call_deferred("_request_done",RESULT_CONNECTION_ERROR,0,StringArray(),ByteArray());
return true;
@@ -531,7 +535,7 @@ int HTTPRequest::get_body_size() const{
void HTTPRequest::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("request","url","custom_headers","ssl_validate_domain"),&HTTPRequest::request,DEFVAL(StringArray()),DEFVAL(true));
+ ObjectTypeDB::bind_method(_MD("request","url","custom_headers","ssl_validate_domain","method","request_data"),&HTTPRequest::request,DEFVAL(StringArray()),DEFVAL(true),DEFVAL(HTTPClient::METHOD_GET),DEFVAL(String()));
ObjectTypeDB::bind_method(_MD("cancel_request"),&HTTPRequest::cancel_request);
ObjectTypeDB::bind_method(_MD("get_http_client_status"),&HTTPRequest::get_http_client_status);
diff --git a/scene/main/http_request.h b/scene/main/http_request.h
index 8dd433982b..705799f044 100644
--- a/scene/main/http_request.h
+++ b/scene/main/http_request.h
@@ -66,6 +66,8 @@ private:
Vector<String> headers;
bool validate_ssl;
bool use_ssl;
+ HTTPClient::Method method;
+ String request_data;
bool request_sent;
Ref<HTTPClient> client;
@@ -114,7 +116,7 @@ protected:
static void _bind_methods();
public:
- Error request(const String& p_url,const Vector<String>& p_custom_headers=Vector<String>(),bool p_ssl_validate_domain=true); //connects to a full url and perform request
+ Error request(const String& p_url, const Vector<String>& p_custom_headers=Vector<String>(), bool p_ssl_validate_domain=true, HTTPClient::Method p_method=HTTPClient::METHOD_GET, const String& p_request_data=""); //connects to a full url and perform request
void cancel_request();
HTTPClient::Status get_http_client_status() const;
diff --git a/scene/main/node.cpp b/scene/main/node.cpp
index 086b69c1c5..1892240426 100644
--- a/scene/main/node.cpp
+++ b/scene/main/node.cpp
@@ -2903,16 +2903,16 @@ void Node::_bind_methods() {
mi.name="rpc";
- ObjectTypeDB::bind_native_method(METHOD_FLAGS_DEFAULT,"rpc",&Node::_rpc_bind,mi);
+ ObjectTypeDB::bind_vararg_method(METHOD_FLAGS_DEFAULT,"rpc",&Node::_rpc_bind,mi);
mi.name="rpc_unreliable";
- ObjectTypeDB::bind_native_method(METHOD_FLAGS_DEFAULT,"rpc_unreliable",&Node::_rpc_unreliable_bind,mi);
+ ObjectTypeDB::bind_vararg_method(METHOD_FLAGS_DEFAULT,"rpc_unreliable",&Node::_rpc_unreliable_bind,mi);
- mi.arguments.push_front( PropertyInfo( Variant::INT, "peer_") );
+ mi.arguments.push_front( PropertyInfo( Variant::INT, "peer_id") );
mi.name="rpc_id";
- ObjectTypeDB::bind_native_method(METHOD_FLAGS_DEFAULT,"rpc_id",&Node::_rpc_id_bind,mi);
+ ObjectTypeDB::bind_vararg_method(METHOD_FLAGS_DEFAULT,"rpc_id",&Node::_rpc_id_bind,mi);
mi.name="rpc_unreliable_id";
- ObjectTypeDB::bind_native_method(METHOD_FLAGS_DEFAULT,"rpc_unreliable_id",&Node::_rpc_unreliable_id_bind,mi);
+ ObjectTypeDB::bind_vararg_method(METHOD_FLAGS_DEFAULT,"rpc_unreliable_id",&Node::_rpc_unreliable_id_bind,mi);
}
diff --git a/scene/main/scene_main_loop.cpp b/scene/main/scene_main_loop.cpp
index 4c7b7c1399..e3472c074a 100644
--- a/scene/main/scene_main_loop.cpp
+++ b/scene/main/scene_main_loop.cpp
@@ -2200,13 +2200,9 @@ void SceneTree::_bind_methods() {
mi.arguments.push_back( PropertyInfo( Variant::INT, "flags"));
mi.arguments.push_back( PropertyInfo( Variant::STRING, "group"));
mi.arguments.push_back( PropertyInfo( Variant::STRING, "method"));
- Vector<Variant> defargs;
- for(int i=0;i<VARIANT_ARG_MAX;i++) {
- mi.arguments.push_back( PropertyInfo( Variant::NIL, "arg"+itos(i)));
- defargs.push_back(Variant());
- }
- ObjectTypeDB::bind_native_method(METHOD_FLAGS_DEFAULT,"call_group",&SceneTree::_call_group,mi,defargs);
+
+ ObjectTypeDB::bind_vararg_method(METHOD_FLAGS_DEFAULT,"call_group",&SceneTree::_call_group,mi);
ObjectTypeDB::bind_method(_MD("set_current_scene","child_node:Node"),&SceneTree::set_current_scene);
ObjectTypeDB::bind_method(_MD("get_current_scene:Node"),&SceneTree::get_current_scene);