|
@@ -96,7 +96,7 @@ Error HTTPRequest::_parse_url(const String& p_url) {
|
|
return OK;
|
|
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);
|
|
ERR_FAIL_COND_V(!is_inside_tree(),ERR_UNCONFIGURED);
|
|
if ( requesting ) {
|
|
if ( requesting ) {
|
|
@@ -104,6 +104,8 @@ Error HTTPRequest::request(const String& p_url, const Vector<String>& p_custom_h
|
|
ERR_FAIL_V(ERR_BUSY);
|
|
ERR_FAIL_V(ERR_BUSY);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ method=p_method;
|
|
|
|
+
|
|
Error err = _parse_url(p_url);
|
|
Error err = _parse_url(p_url);
|
|
if (err)
|
|
if (err)
|
|
return err;
|
|
return err;
|
|
@@ -114,6 +116,8 @@ Error HTTPRequest::request(const String& p_url, const Vector<String>& p_custom_h
|
|
bool has_accept=false;
|
|
bool has_accept=false;
|
|
headers=p_custom_headers;
|
|
headers=p_custom_headers;
|
|
|
|
|
|
|
|
+ request_data = p_request_data;
|
|
|
|
+
|
|
for(int i=0;i<headers.size();i++) {
|
|
for(int i=0;i<headers.size();i++) {
|
|
|
|
|
|
if (headers[i].findn("user-agent:")==0)
|
|
if (headers[i].findn("user-agent:")==0)
|
|
@@ -281,7 +285,7 @@ bool HTTPRequest::_update_connection() {
|
|
switch( client->get_status() ) {
|
|
switch( client->get_status() ) {
|
|
case HTTPClient::STATUS_DISCONNECTED: {
|
|
case HTTPClient::STATUS_DISCONNECTED: {
|
|
call_deferred("_request_done",RESULT_CANT_CONNECT,0,StringArray(),ByteArray());
|
|
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;
|
|
} break;
|
|
case HTTPClient::STATUS_RESOLVING: {
|
|
case HTTPClient::STATUS_RESOLVING: {
|
|
client->poll();
|
|
client->poll();
|
|
@@ -334,7 +338,7 @@ bool HTTPRequest::_update_connection() {
|
|
} else {
|
|
} else {
|
|
//did not request yet, do request
|
|
//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) {
|
|
if (err!=OK) {
|
|
call_deferred("_request_done",RESULT_CONNECTION_ERROR,0,StringArray(),ByteArray());
|
|
call_deferred("_request_done",RESULT_CONNECTION_ERROR,0,StringArray(),ByteArray());
|
|
return true;
|
|
return true;
|
|
@@ -531,7 +535,7 @@ int HTTPRequest::get_body_size() const{
|
|
|
|
|
|
void HTTPRequest::_bind_methods() {
|
|
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("cancel_request"),&HTTPRequest::cancel_request);
|
|
|
|
|
|
ObjectTypeDB::bind_method(_MD("get_http_client_status"),&HTTPRequest::get_http_client_status);
|
|
ObjectTypeDB::bind_method(_MD("get_http_client_status"),&HTTPRequest::get_http_client_status);
|