Permalink
Browse files

Extensionificated!

  • Loading branch information...
hikari-no-yume committed Nov 11, 2013
1 parent 3c293ab commit 4001b9e8d937ec6f0df096d604082d04d9161cf9
Showing with 4 additions and 991 deletions.
  1. BIN Extensions/Faucet HTTP v1.0.gex
  2. +3 −0 Readme.txt
  3. +1 −0 Source/gg2/Extension Packages.xml
  4. +0 −10 Source/gg2/Objects/Networking/HTTP/HttpClient.xml
  5. +0 −4 Source/gg2/Objects/Networking/HTTP/_resources.list.xml
  6. +0 −1 Source/gg2/Objects/Networking/_resources.list.xml
  7. +0 −8 Source/gg2/Scripts/Networking/HTTP/_httpClientDestroy.gml
  8. +0 −55 Source/gg2/Scripts/Networking/HTTP/_httpParseHeader.gml
  9. +0 −98 Source/gg2/Scripts/Networking/HTTP/_httpPrepareRequest.gml
  10. +0 −22 Source/gg2/Scripts/Networking/HTTP/_resources.list.xml
  11. +0 −38 Source/gg2/Scripts/Networking/HTTP/httpConstructUrl.gml
  12. +0 −17 Source/gg2/Scripts/Networking/HTTP/httpGet.gml
  13. +0 −24 Source/gg2/Scripts/Networking/HTTP/httpParseHex.gml
  14. +0 −112 Source/gg2/Scripts/Networking/HTTP/httpParseUrl.gml
  15. +0 −13 Source/gg2/Scripts/Networking/HTTP/httpRequestDestroy.gml
  16. +0 −14 Source/gg2/Scripts/Networking/HTTP/httpRequestError.gml
  17. +0 −19 Source/gg2/Scripts/Networking/HTTP/httpRequestReasonPhrase.gml
  18. +0 −11 Source/gg2/Scripts/Networking/HTTP/httpRequestResponseBody.gml
  19. +0 −11 Source/gg2/Scripts/Networking/HTTP/httpRequestResponseBodyProgress.gml
  20. +0 −13 Source/gg2/Scripts/Networking/HTTP/httpRequestResponseBodySize.gml
  21. +0 −15 Source/gg2/Scripts/Networking/HTTP/httpRequestResponseHeaders.gml
  22. +0 −22 Source/gg2/Scripts/Networking/HTTP/httpRequestStatus.gml
  23. +0 −19 Source/gg2/Scripts/Networking/HTTP/httpRequestStatusCode.gml
  24. +0 −284 Source/gg2/Scripts/Networking/HTTP/httpRequestStep.gml
  25. +0 −95 Source/gg2/Scripts/Networking/HTTP/httpResolvePath.gml
  26. +0 −85 Source/gg2/Scripts/Networking/HTTP/httpResolveUrl.gml
  27. +0 −1 Source/gg2/Scripts/Networking/_resources.list.xml
Binary file not shown.
View
@@ -486,6 +486,9 @@ are intended as a respectful homage.
This game uses the Faucet Networking extension by MedO, which is available under the terms of the ISC license.
You can find more information on Faucet Networking at http://gmc.yoyogames.com/index.php?showtopic=498062.
+This game uses the Faucet HTTP extension by ajf, which is available under the terms of the ISC license.
+You can find more information on Faucet HTTP at https://github.com/TazeTSchnitzel/Faucet-HTTP-Extension
+
This game uses the Faucet Forwarding Extension, created by NAGN, which wraps libminiupnp.
miniupnp is availible under the BSD license: see miniupnp.license for full license.
You can find more about Faucet Forwarding at its GitHub Page:
@@ -1,6 +1,7 @@
<?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>
@@ -1,10 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<object id="815">
- <sprite/>
- <solid>false</solid>
- <visible>false</visible>
- <depth>0</depth>
- <persistent>true</persistent>
- <parent/>
- <mask/>
-</object>
@@ -1,4 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<resources>
- <resource name="HttpClient" type="RESOURCE"/>
-</resources>
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<resources>
- <resource name="HTTP" type="GROUP"/>
<resource name="GameServer" type="RESOURCE"/>
<resource name="Client" type="RESOURCE"/>
<resource name="RewardAuthChecker" type="RESOURCE"/>
@@ -1,8 +0,0 @@
-// 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;
@@ -1,55 +0,0 @@
-// Internal function - parses header
-// real _httpParseHeader(string linebuf, real line)
-// Returns false if it errored (caller should return and destroy)
-
-var linebuf, line;
-linebuf = argument0;
-line = argument1;
-
-// "HTTP/1.1 header field values can be folded onto multiple lines if the
-// continuation line begins with a space or horizontal tab."
-if ((string_char_at(linebuf, 1) == ' ' or ord(string_char_at(linebuf, 1)) == 9))
-{
- if (line == 1)
- {
- errored = true;
- error = "First header line of response can't be a continuation, right?";
- return false;
- }
- headerValue = ds_map_find_value(responseHeaders, string_lower(headerName))
- + string_copy(linebuf, 2, string_length(linebuf) - 1);
-}
-// "Each header field consists
-// of a name followed by a colon (":") and the field value. Field names
-// are case-insensitive. The field value MAY be preceded by any amount
-// of LWS, though a single SP is preferred."
-else
-{
- var colonPos;
- colonPos = string_pos(':', linebuf);
- if (colonPos == 0)
- {
- errored = true;
- error = "No colon in a header line of response";
- return false;
- }
- headerName = string_copy(linebuf, 1, colonPos - 1);
- headerValue = string_copy(linebuf, colonPos + 1, string_length(linebuf) - colonPos);
- // "The field-content does not include any leading or trailing LWS:
- // linear white space occurring before the first non-whitespace
- // character of the field-value or after the last non-whitespace
- // character of the field-value. Such leading or trailing LWS MAY be
- // removed without changing the semantics of the field value."
- while (string_char_at(headerValue, 1) == ' ' or ord(string_char_at(headerValue, 1)) == 9)
- headerValue = string_copy(headerValue, 2, string_length(headerValue) - 1);
-}
-
-ds_map_add(responseHeaders, string_lower(headerName), headerValue);
-
-if (string_lower(headerName) == 'content-length')
-{
- responseBodySize = real(headerValue);
- responseBodyProgress = 0;
-}
-
-return true;
@@ -1,98 +0,0 @@
-// Internal function - prepares request
-// void httpRequestGet(real client, string url, real headers)
-
-// client - HttpClient object to prepare
-// url - URL to send GET request to
-// headers - ds_map of extra headers to send, -1 if none
-
-
-var client, url, headers;
-client = argument0;
-url = argument1;
-headers = argument2;
-
-var parsed;
-parsed = httpParseUrl(url);
-
-if (parsed == -1)
- show_error("Error when making HTTP GET request - can't parse URL: " + url, true);
-
-if (!ds_map_exists(parsed, 'port'))
- ds_map_add(parsed, 'port', 80);
-if (!ds_map_exists(parsed, 'abs_path'))
- ds_map_add(parsed, 'abs_path', '/');
-
-with (client)
-{
- destroyed = false;
- CR = chr(13);
- LF = chr(10);
- CRLF = CR + LF;
- socket = tcp_connect(ds_map_find_value(parsed, 'host'), ds_map_find_value(parsed, 'port'));
- state = 0;
- errored = false;
- error = '';
- linebuf = '';
- line = 0;
- statusCode = -1;
- reasonPhrase = '';
- responseBody = buffer_create();
- responseBodySize = -1;
- responseBodyProgress = -1;
- responseHeaders = ds_map_create();
- requestUrl = url;
- requestHeaders = headers;
-
- // Request = Request-Line ; Section 5.1
- // *(( general-header ; Section 4.5
- // | request-header ; Section 5.3
- // | entity-header ) CRLF) ; Section 7.1
- // CRLF
- // [ message-body ] ; Section 4.3
-
- // "The Request-Line begins with a method token, followed by the
- // Request-URI and the protocol version, and ending with CRLF. The
- // elements are separated by SP characters. No CR or LF is allowed
- // except in the final CRLF sequence."
- if (ds_map_exists(parsed, 'query'))
- write_string(socket, 'GET ' + ds_map_find_value(parsed, 'abs_path') + '?' + ds_map_find_value(parsed, 'query') + ' HTTP/1.1' + CRLF);
- else
- write_string(socket, 'GET ' + ds_map_find_value(parsed, 'abs_path') + ' HTTP/1.1' + CRLF);
-
- // "A client MUST include a Host header field in all HTTP/1.1 request
- // messages."
- // "A "host" without any trailing port information implies the default
- // port for the service requested (e.g., "80" for an HTTP URL)."
- if (ds_map_find_value(parsed, 'port') == 80)
- write_string(socket, 'Host: ' + ds_map_find_value(parsed, 'host') + CRLF);
- else
- write_string(socket, 'Host: ' + ds_map_find_value(parsed, 'host')
- + ':' + string(ds_map_find_value(parsed, 'port')) + CRLF);
-
- // "An HTTP/1.1 server MAY assume that a HTTP/1.1 client intends to
- // maintain a persistent connection unless a Connection header including
- // the connection-token "close" was sent in the request."
- write_string(socket, 'Connection: close' + CRLF);
-
- // "If no Accept-Encoding field is present in a request, the server MAY
- // assume that the client will accept any content coding."
- write_string(socket, 'Accept-Encoding:' + CRLF);
-
- // If headers specified
- if (headers != -1)
- {
- var key;
- // Iterate over headers map
- for (key = ds_map_find_first(headers); is_string(key); key = ds_map_find_next(headers, key))
- {
- write_string(socket, key + ': ' + ds_map_find_value(headers, key) + CRLF);
- }
- }
-
- // Send extra CRLF to terminate request
- write_string(socket, CRLF);
-
- socket_send(socket);
-
- ds_map_destroy(parsed);
-}
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<resources>
- <resource name="httpParseUrl" type="RESOURCE"/>
- <resource name="httpResolveUrl" type="RESOURCE"/>
- <resource name="httpResolvePath" type="RESOURCE"/>
- <resource name="httpParseHex" type="RESOURCE"/>
- <resource name="httpConstructUrl" type="RESOURCE"/>
- <resource name="httpGet" type="RESOURCE"/>
- <resource name="_httpPrepareRequest" type="RESOURCE"/>
- <resource name="_httpParseHeader" type="RESOURCE"/>
- <resource name="_httpClientDestroy" type="RESOURCE"/>
- <resource name="httpRequestStep" type="RESOURCE"/>
- <resource name="httpRequestStatus" type="RESOURCE"/>
- <resource name="httpRequestError" type="RESOURCE"/>
- <resource name="httpRequestStatusCode" type="RESOURCE"/>
- <resource name="httpRequestReasonPhrase" type="RESOURCE"/>
- <resource name="httpRequestResponseBody" type="RESOURCE"/>
- <resource name="httpRequestResponseBodySize" type="RESOURCE"/>
- <resource name="httpRequestResponseBodyProgress" type="RESOURCE"/>
- <resource name="httpRequestResponseHeaders" type="RESOURCE"/>
- <resource name="httpRequestDestroy" type="RESOURCE"/>
-</resources>
@@ -1,38 +0,0 @@
-// Constructs an URL from its components (as httpParseUrl would return)
-// string httpConstructUrl(real parts)
-
-// Return value is the string of the constructed URL
-// Keys of parts map:
-// "scheme" - the URL scheme (e.g. "http")
-// "host" - the hostname (e.g. "example.com" or "127.0.0.1")
-// "port" - the port (e.g. 8000) - this is a real, unlike the others
-// "abs_path" - the absolute path (e.g. "/" or "/index.html")
-// "query" - the query string (e.g. "a=b&c=3")
-// Parts which are omitted will be omitted in the URL
-// e.g. http://example.com lacks "port", "path" or "query" keys
-
-// This will *only* work properly for URLs of format:
-// scheme ":" "//" host [ ":" port ] [ abs_path [ "?" query ]]"
-// where [] denotes an optional component
-// file: URLs will *not* work as they lack the authority (host:port) component
-// Should work correctly for IPv6 host values, but bare in mind parse_url won't
-
-var parts;
-parts = argument0;
-
-var url;
-url = '';
-
-url += ds_map_find_value(parts, 'scheme');
-url += '://';
-url += ds_map_find_value(parts, 'host');
-if (ds_map_exists(parts, 'port'))
- url += ':' + string(ds_map_find_value(parts, 'port'));
-if (ds_map_exists(parts, 'abs_path'))
-{
- url += ds_map_find_value(parts, 'abs_path');
- if (ds_map_exists(parts, 'query'))
- url += '?' + ds_map_find_value(parts, 'query');
-}
-
-return url;
@@ -1,17 +0,0 @@
-// Makes a GET HTTP request
-// real httpRequestGet(string url, real headers[, real overwrite])
-
-// url - URL to send GET request to
-// headers - ds_map of extra headers to send, -1 if none
-
-// Return value is an HttpClient instance that can be passed to httpRequestStatus etc.
-// (errors on failure to parse URL)
-
-var url, headers, client;
-
-url = argument0;
-headers = argument1;
-
-client = instance_create(0, 0, HttpClient);
-_httpPrepareRequest(client, url, headers);
-return client;
@@ -1,24 +0,0 @@
-// Takes a lowercase hexadecimal string and returns its integer value
-// real httpParseHex(string hexString)
-
-// Return value is the whole number value (or -1 if invalid)
-// Only works for whole numbers (non-fractional numbers >= 0) and lowercase hex
-
-var hexString;
-hexString = argument0;
-
-var result, hexValues;
-result = 0;
-hexValues = "0123456789abcdef";
-
-var i;
-for (i = 1; i <= string_length(hexString); i += 1) {
- result *= 16;
- var digit;
- digit = string_pos(string_char_at(hexString, i), hexValues) - 1;
- if (digit == -1)
- return -1;
- result += digit;
-}
-
-return result;
Oops, something went wrong.

0 comments on commit 4001b9e

Please sign in to comment.