{"id":13678354,"url":"https://github.com/andyburke/UnityHTTP","last_synced_at":"2025-04-29T13:30:25.081Z","repository":{"id":2532179,"uuid":"3508927","full_name":"andyburke/UnityHTTP","owner":"andyburke","description":"A TcpClient-based HTTP library for Unity.","archived":false,"fork":false,"pushed_at":"2017-09-13T01:47:31.000Z","size":405,"stargazers_count":595,"open_issues_count":18,"forks_count":147,"subscribers_count":64,"default_branch":"master","last_synced_at":"2024-10-19T02:44:44.366Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/andyburke.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-02-21T22:27:56.000Z","updated_at":"2024-10-14T03:25:19.000Z","dependencies_parsed_at":"2022-07-08T19:39:21.131Z","dependency_job_id":null,"html_url":"https://github.com/andyburke/UnityHTTP","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andyburke%2FUnityHTTP","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andyburke%2FUnityHTTP/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andyburke%2FUnityHTTP/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andyburke%2FUnityHTTP/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andyburke","download_url":"https://codeload.github.com/andyburke/UnityHTTP/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224173789,"owners_count":17268178,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T13:00:52.691Z","updated_at":"2024-11-11T20:31:26.208Z","avatar_url":"https://github.com/andyburke.png","language":"C#","readme":"# Attribution\n\nBased on Simon Wittber's UnityWeb code (http://code.google.com/p/unityweb/).\n\n# LICENSE\n\nUnityHTTP falls under the GPL due to its basis on Simon Wittber's UnityWeb code,\nwhich is licensed under the GPL.\n\nYou should be aware of this license and determine if it is acceptable for your project.\n\n# About\n\nThis is a TcpClient-based HTTP library for use in Unity.  It should work in\nboth the standalone player and in the web player.\n\nIt also has convenience methods for working with JSON.\n# Examples\n\nIEnumerator example:\n\n```C#\npublic IEnumerator SomeRoutine() {\n    HTTP.Request someRequest = new HTTP.Request( \"get\", \"http://someurl.com/somewhere\" );\n    someRequest.Send();\n\n    while( !someRequest.isDone )\n    {\n        yield return null;\n    }\n\n    // parse some JSON, for example:\n    JSONObject thing = new JSONObject( request.response.Text );\n}\n```\n\nClosure-style (does not need to be in a coroutine):\n\n```C#\nHTTP.Request someRequest = new HTTP.Request( \"get\", \"http://someurl.com/somewhere\" );\nsomeRequest.Send( ( request ) =\u003e {\n    // parse some JSON, for example:\n    JSONObject thing = new JSONObject( request.response.Text );\n});\n```\n\nPost request using form data:\n\n```C#\nWWWForm form = new WWWForm();\nform.AddField( \"something\", \"yo\" );\nform.AddField( \"otherthing\", \"hey\" );\n\nHTTP.Request someRequest = new HTTP.Request( \"post\", \"http://someurl.com/some/post/handler\", form );\nsomeRequest.Send( ( request ) =\u003e {\n    // parse some JSON, for example:\n    bool result = false;\n    Hashtable thing = (Hashtable)JSON.JsonDecode( request.response.Text, ref result );\n    if ( !result )\n    {\n        Debug.LogWarning( \"Could not parse JSON response!\" );\n        return;\n    }\n});\n```\n\nPost request using JSON:\n\n```C#\nHashtable data = new Hashtable();\ndata.Add( \"something\", \"hey!\" );\ndata.Add( \"otherthing\", \"YO!!!!\" );\n\n// When you pass a Hashtable as the third argument, we assume you want it send as JSON-encoded\n// data.  We'll encode it to JSON for you and set the Content-Type header to application/json\nHTTP.Request theRequest = new HTTP.Request( \"post\", \"http://someurl.com/a/json/post/handler\", data );\ntheRequest.Send( ( request ) =\u003e {\n\n    // we provide Object and Array convenience methods that attempt to parse the response as JSON\n    // if the response cannot be parsed, we will return null\n    // note that if you want to send json that isn't either an object ({...}) or an array ([...])\n    // that you should use JSON.JsonDecode directly on the response.Text, Object and Array are\n    // only provided for convenience\n    Hashtable result = request.response.Object;\n    if ( result == null )\n    {\n        Debug.LogWarning( \"Could not parse JSON response!\" );\n        return;\n    }\n  \n});\n```\n\nIf you want to make a request while not in Play Mode (e. g. from a custom Editor menu command or wizard), you must use the Request synchronously, since Unity's main update loop is not running. The call will block until the response is available.\n\n```C#\nHashtable data = new Hashtable();\ndata.Add( \"something\", \"hey!\" );\ndata.Add( \"otherthing\", \"YO!!!!\" );\n\nHTTP.Request theRequest = new HTTP.Request(\"post\", \"http://someurl.com/a/json/post/handler\", data );\ntheRequest.synchronous = true;\ntheRequest.Send((request) =\u003e {\n\tEditorUtility.DisplayDialog(\"Request was posted.\", request.response.Text, \"Ok\");\n});\n```\n\n","funding_links":[],"categories":["NetWork","Open Source Repositories","Networks","Open Source Packages"],"sub_categories":["Networking"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandyburke%2FUnityHTTP","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandyburke%2FUnityHTTP","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandyburke%2FUnityHTTP/lists"}