Skip to content

Commit

Permalink
Merge pull request #346 from bsarsgard/4.x
Browse files Browse the repository at this point in the history
Fixes an issue with HTTPRequest on web exports
  • Loading branch information
WolfgangSenff authored Jul 4, 2023
2 parents 67923d8 + 37cd3f8 commit 12f56be
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 1 deletion.
8 changes: 8 additions & 0 deletions addons/godot-firebase/Utilies.gd
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,11 @@ static func get_json_data(value):
return json.data

return null


# HTTPRequeust seems to have an issue in Web exports where the body returns empty
# This appears to be caused by the gzip compression being unsupported, so we
# disable it when web export is detected.
static func fix_http_request(http_request):
if OS.get_name() == "HTML5" or OS.get_name() == "Web":
http_request.accept_gzip = false
3 changes: 2 additions & 1 deletion addons/godot-firebase/auth/auth.gd
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,8 @@ func _ready() -> void:
tcp_timer.wait_time = tcp_timeout
tcp_timer.timeout.connect(_tcp_stream_timer)

if OS.get_name() == "HTML5":
Utilities.fix_http_request(self)
if OS.get_name() == "HTML5" or OS.get_name() == "Web":
_local_uri += "tmp_js_export.html"


Expand Down
1 change: 1 addition & 0 deletions addons/godot-firebase/database/database.gd
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ func _on_FirebaseAuth_logout() -> void:
func get_database_reference(path : String, filter : Dictionary = {}) -> FirebaseDatabaseReference:
var firebase_reference : FirebaseDatabaseReference = FirebaseDatabaseReference.new()
var pusher : HTTPRequest = HTTPRequest.new()
Utilities.fix_http_request(pusher)
pusher.use_threads = true
var listener : Node = Node.new()
listener.set_script(load("res://addons/http-sse-client/HTTPSSEClient.gd"))
Expand Down
1 change: 1 addition & 0 deletions addons/godot-firebase/dynamiclinks/dynamiclinks.gd
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ enum Requests {
func _set_config(config_json : Dictionary) -> void:
_config = config_json
_request_list_node = HTTPRequest.new()
Utilities.fix_http_request(_request_list_node)
_request_list_node.request_completed.connect(_on_request_completed)
add_child(_request_list_node)
_check_emulating()
Expand Down
1 change: 1 addition & 0 deletions addons/godot-firebase/firestore/firestore.gd
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ func _pooled_request(task : FirestoreTask) -> void:
if not http_request:
http_request = HTTPRequest.new()
http_request.timeout = 5
Utilities.fix_http_request(http_request)
_http_request_pool.append(http_request)
add_child(http_request)
http_request.request_completed.connect(_on_pooled_request_completed.bind(http_request))
Expand Down
1 change: 1 addition & 0 deletions addons/godot-firebase/functions/functions.gd
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ func _pooled_request(task : FunctionTask) -> void:

if not http_request:
http_request = HTTPRequest.new()
Utilities.fix_http_request(http_request)
_http_request_pool.append(http_request)
add_child(http_request)
http_request.request_completed.connect(_on_pooled_request_completed.bind(http_request))
Expand Down

0 comments on commit 12f56be

Please sign in to comment.