// Main thread constructor private IEnumerator Constructor(string url, string contentType, byte[] postData, Dictionary <string, string> headers, CookieContainer cookies, Action <Exception, string> cb) { Dictionary <string, string> headersCopy = (headers != null) ? new Dictionary <string, string>(headers) : new Dictionary <string, string>(); // Set content type if provided if (contentType != null) { headersCopy.Add("ContentType", contentType); } // Set cookies if provided if (cookies != null) { Uri requestUri = new Uri(url); string cookieString = cookies.GetCookieHeader(requestUri); if (!string.IsNullOrEmpty(cookieString)) { headersCopy.Add("Cookie", cookieString); } } // Setup private properties and fire off the request this.cb = cb; this.cookies = cookies; request = new WWW(url, postData, headersCopy); // Initiate response HttpRequestManager.Queue(WaitLoop()); yield break; }
// Constructor public HttpRequest(string url, string contentType, byte[] postData, Dictionary <string, string> headers, CookieContainer cookies, Action <Exception, string> cb) { // Start timeout timer timeoutTimer.Start(); // Queue constructor for main thread execution HttpRequestManager.Queue(Constructor(url, contentType, postData, headers, cookies, cb)); }