internal static IEnumerator SendRequest(HttpRequest request, Action <int /*statusCode*/, string /*data*/, string /*error*/> completionHandler)
{
WWW www;
if (request.HTTPMethod == HttpRequest.HTTPMethodType.POST)
{
Dictionary <string, string> headers = new Dictionary <string, string>();
WWWForm form = new WWWForm();
foreach (var entry in Utils.HashtableToDictionary <string, string>(form.headers))
{
headers[entry.Key] = entry.Value;
}
foreach (var entry in request.getHeaders())
{
headers[entry.Key] = entry.Value;
}
byte[] bytes = Encoding.UTF8.GetBytes(request.HTTPBody);
www = new WWW(request.URL, bytes, headers);
}
else
{
www = new WWW(request.URL);
}
yield return(www);
int statusCode = ReadStatusCode(www);
string data = www.text;
string error = www.error;
if (completionHandler != null)
{
completionHandler(statusCode, data, error);
}
}