<commit_before>﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Assets.Sources.Core.HTTP;
using UnityEngine;
using UnityEngine.Networking;

namespace Assets.Sources.Core.Network
{
    public class HttpClient
    {
        public static readonly HttpClient Instance=new HttpClient();
        private HttpClient()
        {
            
        }

        public void Get(Action<string> action )
        {
            HttpTool.Instance.StartCoroutine(WaitUntilResponseReceived(action));
        }

        private IEnumerator WaitUntilResponseReceived(Action<string> action)
        {
            using (UnityWebRequest www = UnityWebRequest.Get("http://www.cnblogs.com"))
            {
                yield return www.Send();

                if (www.isError)
                {
                    Debug.Log(www.error);
                }
                else
                {
                    // Show results as text
                    //Debug.Log(www.downloadHandler.text);

                    action(www.downloadHandler.text);
                    // Or retrieve results as binary data
                    byte[] results = www.downloadHandler.data;
                }
            }
        }
    }
}<commit_msg>HttpClient.POST实现<commit_after>﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Assets.Sources.Core.HTTP;
using UnityEngine;
using UnityEngine.Networking;

namespace Assets.Sources.Core.Network
{
    public class HttpClient
    {
        public static readonly HttpClient Instance=new HttpClient();
        private HttpClient()
        {
            
        }

        public void Get(Action<string> action )
        {
            HttpTool.Instance.StartCoroutine(WaitUntilResponseReceived(action));
        }

        public void Post()
        {
            HttpTool.Instance.StartCoroutine(Upload());
        }

        private IEnumerator WaitUntilResponseReceived(Action<string> action)
        {
            using (UnityWebRequest www = UnityWebRequest.Get("http://www.cnblogs.com"))
            {
                yield return www.Send();

                if (www.isError)
                {
                    Debug.Log(www.error);
                }
                else
                {
                    // Show results as text
                    //Debug.Log(www.downloadHandler.text);

                    action(www.downloadHandler.text);
                    // Or retrieve results as binary data
                    byte[] results = www.downloadHandler.data;
                }
            }
        }

        private IEnumerator Upload()
        {
            WWWForm form = new WWWForm();
            form.AddField("myField", "myData");

            using (UnityWebRequest www = UnityWebRequest.Post("http://www.my-server.com/myform", form))
            {
                yield return www.Send();

                if (www.isError)
                {
                    Debug.Log(www.error);
                }
                else
                {
                    Debug.Log("Form upload complete!");
                }
            }
        }
    }
}
{'fraction_non_alphanumeric': 0.08919170021678538, 'fraction_numerical': 0.0, 'mean_word_length': 1.3872875092387287, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 21, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2353660', 'n_tokens_mistral': 813, 'n_tokens_neox': 770, 'n_words': 156}