Permalink
Browse files

Faucet HTTP v1.0

  • Loading branch information...
1 parent 1d2375a commit 82526091c82fd3ae09b6288500d3b3ae019ac45a @hikari-no-yume hikari-no-yume committed Jan 11, 2014
Showing with 1,490 additions and 98 deletions.
  1. BIN Extensions/Faucet HTTP v1.1.gex
  2. +0 −1 Source/gg2/Extension Packages.xml
  3. +1 −1 Source/gg2/Objects/Menus/BackgroundDownloader.events/Create.xml
  4. +6 −16 Source/gg2/Objects/Menus/BackgroundDownloader.events/Step.xml
  5. +1 −1 Source/gg2/Objects/Menus/DevMessageChecker.events/Create.xml
  6. +5 −24 Source/gg2/Objects/Menus/DevMessageChecker.events/Step.xml
  7. +10 −21 Source/gg2/Objects/Updater.events/Create.xml
  8. +27 −0 Source/gg2/Scripts/Faucet HTTP/__http_client_destroy.gml
  9. +307 −0 Source/gg2/Scripts/Faucet HTTP/__http_client_step.gml
  10. +57 −0 Source/gg2/Scripts/Faucet HTTP/__http_construct_url.gml
  11. +24 −0 Source/gg2/Scripts/Faucet HTTP/__http_init.gml
  12. +74 −0 Source/gg2/Scripts/Faucet HTTP/__http_parse_header.gml
  13. +43 −0 Source/gg2/Scripts/Faucet HTTP/__http_parse_hex.gml
  14. +131 −0 Source/gg2/Scripts/Faucet HTTP/__http_parse_url.gml
  15. +116 −0 Source/gg2/Scripts/Faucet HTTP/__http_prepare_request.gml
  16. +114 −0 Source/gg2/Scripts/Faucet HTTP/__http_resolve_path.gml
  17. +104 −0 Source/gg2/Scripts/Faucet HTTP/__http_resolve_url.gml
  18. +52 −0 Source/gg2/Scripts/Faucet HTTP/__http_split.gml
  19. +24 −0 Source/gg2/Scripts/Faucet HTTP/_resources.list.xml
  20. +32 −0 Source/gg2/Scripts/Faucet HTTP/http_destroy.gml
  21. +38 −0 Source/gg2/Scripts/Faucet HTTP/http_new_get.gml
  22. +40 −0 Source/gg2/Scripts/Faucet HTTP/http_new_get_ex.gml
  23. +47 −0 Source/gg2/Scripts/Faucet HTTP/http_reason_phrase.gml
  24. +30 −0 Source/gg2/Scripts/Faucet HTTP/http_response_body.gml
  25. +30 −0 Source/gg2/Scripts/Faucet HTTP/http_response_body_progress.gml
  26. +32 −0 Source/gg2/Scripts/Faucet HTTP/http_response_body_size.gml
  27. +34 −0 Source/gg2/Scripts/Faucet HTTP/http_response_headers.gml
  28. +48 −0 Source/gg2/Scripts/Faucet HTTP/http_status_code.gml
  29. +47 −0 Source/gg2/Scripts/Faucet HTTP/http_step.gml
  30. +7 −16 Source/gg2/Scripts/Plugins/getpluginhashes.gml
  31. +8 −18 Source/gg2/Scripts/Plugins/loadserverplugins.gml
  32. +1 −0 Source/gg2/Scripts/_resources.list.xml
Binary file not shown.
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<extensionPackages>
<package>Faucet Forwarding</package>
- <package>Faucet HTTP</package>
<package>Faucet Networking</package>
<package>GG2DLL</package>
</extensionPackages>
@@ -20,7 +20,7 @@ showVersion = true;
tmpfile = temp_directory + "\background.png.tmp";
-handle = http_get(BACKGROUND_SOURCE, -1);
+handle = http_new_get(BACKGROUND_SOURCE);
</argument>
</arguments>
</action>
@@ -13,28 +13,18 @@
<not>false</not>
<appliesTo>.self</appliesTo>
<arguments>
- <argument kind="STRING">http_request_step(handle);
-
-// Errored
-if (http_request_status(handle) == 2)
-{
- show_message(http_request_error(handle));
- instance_destroy();
- exit;
-}
-// Finished
-else if (http_request_status(handle) == 1)
-{
+ <argument kind="STRING">// Finished/Errored
+if (http_step(handle)) {
// Request failed
- if (http_request_status_code(handle) != 200)
+ if (http_status_code(handle) != 200)
{
- show_message(http_request_reason_phrase(handle));
+ show_message(http_reason_phrase(handle));
instance_destroy();
exit;
}
- write_buffer_to_file(http_request_response_body(handle), tmpfile);
- http_request_destroy(handle);
+ write_buffer_to_file(http_response_body(handle), tmpfile);
+ http_destroy(handle);
// File doesn't exist
if (!file_exists(tmpfile))
@@ -31,7 +31,7 @@ if(global.updaterBetaChannel)
else
url = DEVMESSAGES_SOURCE;
-handle = http_get(url, -1);
+handle = http_new_get(url);
image_speed = 5/room_speed;
</argument>
@@ -15,38 +15,19 @@
<arguments>
<argument kind="STRING">image_speed = 5/room_speed;
-http_request_step(handle);
-
-var status;
-status = http_request_status(handle);
-
-// Request failed
-if (status == 2)
-{
- // Just give up
- http_request_destroy(handle);
- instance_destroy();
- exit;
-}
-// Request finished
-else if (status == 1)
-{
- var statusCode;
- statusCode = http_request_status_code(handle);
-
+if (http_step(handle)) {
// Request failed
- if (statusCode != 200)
- {
+ if (http_status_code(handle) != 200) {
// Just give up
- http_request_destroy(handle);
+ http_destroy(handle);
instance_destroy();
exit;
}
var data;
- data = http_request_response_body(handle);
+ data = http_response_body(handle);
data = read_string(data, buffer_size(data));
- http_request_destroy(handle);
+ http_destroy(handle);
global.devMessagesChecked = true;
@@ -31,18 +31,17 @@ else
tmpfile = temp_directory + "\gg2update.zip";
-downloadHandle = http_get(url, -1);
+downloadHandle = http_new_get(url);
-while(!http_request_status(downloadHandle))
+while(!http_step(downloadHandle))
{ // while download isn't finished
sleep(floor(1000/30)); // sleep for the equivalent of one frame
io_handle(); // this prevents GameMaker from appearing locked-up
- http_request_step(downloadHandle);
// check if the user cancelled the download with the esc key
if(keyboard_check(vk_escape))
{
- http_request_destroy(downloadHandle);
+ http_destroy(downloadHandle);
window_set_showborder(window_oldshowborder);
window_set_fullscreen(window_oldfullscreen);
room_goto_fix(Menu);
@@ -60,8 +59,8 @@ while(!http_request_status(downloadHandle))
draw_text(x,y-20,string(minutes) + " minutes " + string(seconds) + " seconds Remaining...");
counter+=1;
var progress, size;
- progress = http_request_response_body_progress(downloadHandle);
- size = http_request_response_body_size(downloadHandle);
+ progress = http_response_body_progress(downloadHandle);
+ size = http_response_body_size(downloadHandle);
if (size != -1)
{
progressBar = floor((progress/size) * 20);
@@ -74,28 +73,18 @@ while(!http_request_status(downloadHandle))
screen_refresh();
}
// Errored
-if (http_request_status(downloadHandle) == 2)
+if (http_status_code(downloadHandle) != 200)
{
- show_message("Downloading update failed!#" + http_request_error(downloadHandle));
- http_request_destroy(downloadHandle);
- window_set_showborder(window_oldshowborder);
- window_set_fullscreen(window_oldfullscreen);
- room_goto_fix(Menu);
- exit;
-}
-// Request failed
-if (http_request_status_code(downloadHandle) != 200)
-{
- show_message("Downloading update failed!#" + string(http_request_status_code(downloadHandle)) + " " + http_request_reason_phrase(downloadHandle));
- http_request_destroy(downloadHandle);
+ show_message("Downloading update failed!#" + string(http_status_code(downloadHandle)) + " " + http_reason_phrase(downloadHandle));
+ http_destroy(downloadHandle);
window_set_showborder(window_oldshowborder);
window_set_fullscreen(window_oldfullscreen);
room_goto_fix(Menu);
exit;
}
-write_buffer_to_file(http_request_response_body(downloadHandle), tmpfile);
-http_request_destroy(downloadHandle);
+write_buffer_to_file(http_response_body(downloadHandle), tmpfile);
+http_destroy(downloadHandle);
if(!file_exists(tmpfile))
{
@@ -0,0 +1,27 @@
+// ***
+// This function forms part of Faucet HTTP v1.0
+// https://github.com/TazeTSchnitzel/Faucet-HTTP-Extension
+//
+// Copyright (c) 2013-2014, Andrea Faulds <ajf@ajf.me>
+//
+// Permission to use, copy, modify, and/or distribute this software for any
+// purpose with or without fee is hereby granted, provided that the above
+// copyright notice and this permission notice appear in all copies.
+//
+// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+// ***
+
+// Clears up contents of an httpClient prior to destruction or after error
+
+if (!destroyed) {
+ socket_destroy(socket);
+ buffer_destroy(responseBody);
+ ds_map_destroy(responseHeaders);
+}
+destroyed = true;
Oops, something went wrong.

0 comments on commit 8252609

Please sign in to comment.