IEnumerator DemoSimple()
  {
    _test = "DemoSimple";

    using (_client = new HTTPClient("unity3d.com"))
    {
      yield return StartCoroutine(_client.WaitUntilDone());
      DebugAll(_client);
    }
  }
  IEnumerator DemoFormPost()
  {
    _test = "DemoFormPost";

    HTTPRequest request = new HTTPRequest();

    request.SetURL("http://www.hashemian.com/tools/form-post-tester.php/test123").
      SetContentString("foo=bar&cafe=babe", "application/octet-stream").
      Post();

    using (_client = new HTTPClient(request))
    {
      yield return StartCoroutine(_client.WaitUntilDone());
      DebugAll(_client);
    }
  }
  IEnumerator DemoFilePost()
  {
    _test = "DemoFilePost";

    string srcPath = Application.temporaryCachePath;
    srcPath = System.IO.Path.Combine(srcPath, "data");
    byte[] data = Encoding.UTF8.GetBytes("hello\nworld\n!!!");

    using (FileStream stream = new FileStream(srcPath, FileMode.Create,
          FileAccess.Write, FileShare.ReadWrite))
    {
      stream.Write(data, 0, data.Length);
    }

    HTTPRequest request = new HTTPRequest();

    request.SetURL("http://www.hashemian.com/tools/form-post-tester.php/test123").
      SetContentFromPath(srcPath, "application/octet-stream").
      Post();

    using (_client = new HTTPClient(request))
    {
      yield return StartCoroutine(_client.WaitUntilDone());
      DebugAll(_client);
    }
  }
  IEnumerator DemoCacheControl()
  {
    _test = "DemoCacheControl";

    HTTPRequest request = new HTTPRequest();

    request.SetURL("http://www.google.com").
      AppendQueryParameter("q", "unity");

    HTTPResponseMemoryStreamHandler responseHandler =
      new HTTPResponseMemoryStreamHandler();

    responseHandler.SetCachePolicy(CachePolicy.ReloadIgnoringLocalAndRemoteCacheData);

    using (_client = new HTTPClient(request, responseHandler))
    {
      yield return StartCoroutine(_client.WaitUntilDone());
      DebugAll(_client);
    }
  }
  IEnumerator DemoErrorHandling()
  {
    _test = "DemoErrorHandling";

    HTTPRequest request = new HTTPRequest();

    request.SetURL("http://www.wikipeeeeeedia.com");

    using (_client = new HTTPClient(request))
    {
      yield return StartCoroutine(_client.WaitUntilDone());
      DebugAll(_client);

      Error err = _client.Error;
      if (err != null)
      {
        _log += "\n\nIs Host Lookup Error? " +
          (err.IsKnownCode(Error.KnownCode.HostLookupError) ? "YES" : "NO");
      }
    }
  }
  IEnumerator DemoRedirectControl()
  {
    _test = "DemoRedirectControl";

    HTTPRequest request = new HTTPRequest();

    request.SetURL("https://google.com").
      AppendQueryParameter("q", "unity");

    HTTPResponseMemoryStreamHandler responseHandler =
      new HTTPResponseMemoryStreamHandler();

    responseHandler.SetAllowFollowRedirects(true);
    responseHandler.SetMaxRedirectCount(10);

    using (_client = new HTTPClient(request, responseHandler))
    {
      yield return StartCoroutine(_client.WaitUntilDone());
      DebugAll(_client);
    }
  }
  IEnumerator DemoTimeoutControl()
  {
    _test = "DemoTimeoutControl";

    HTTPRequest request = new HTTPRequest();

    request.SetURL("http://www.wikipedia.com");

    using (_client = new HTTPClient(request))
    {
      _client.ConnectionTimeout = 0.01f;
      yield return StartCoroutine(_client.WaitUntilDone());
      DebugAll(_client);

      Error err = _client.Error;
      if (err != null)
      {
        _log += "\n\nIs Timeout Error? " +
          (err.IsKnownCode(Error.KnownCode.ConnectionTimeoutError) ? "YES" : "NO");
      }
    }
  }
  IEnumerator DemoBasicAuthClient()
  {
    _test = "DemoBasicAuthClient";

    HTTPRequest request = new HTTPRequest();

    request.SetURL("http://browserspy.dk/password-ok.php").
      SetAuthCredential("test", "test");

    using (_client = new HTTPClient(request))
    {
      yield return StartCoroutine(_client.WaitUntilDone());
      DebugAll(_client);
    }
  }
  IEnumerator DemoAcceptInvalidHTTPSCertificates()
  {
    _test = "DemoAcceptInvalidHTTPSCertificates";

    HTTPRequest request = new HTTPRequest();

    request.SetURL("https://google.com").
      AppendQueryParameter("q", "unity");

    HTTPResponseMemoryStreamHandler responseHandler =
      new HTTPResponseMemoryStreamHandler();

    responseHandler.SetAllowInvalidSSLCertificates(true);

    using (_client = new HTTPClient(request, responseHandler))
    {
      yield return StartCoroutine(_client.WaitUntilDone());
      DebugAll(_client);
    }
  }
  IEnumerator DemoHTTPS()
  {
    _test = "DemoHTTPS";

    HTTPRequest request = new HTTPRequest();

    request.SetURL("https://google.com").
      AppendQueryParameter("q", "unity");

    using (_client = new HTTPClient(request))
    {
      yield return StartCoroutine(_client.WaitUntilDone());
      DebugAll(_client);
    }
  }
  IEnumerator DemoAcceptableStatusCodes()
  {
    _test = "DemoAcceptableStatusCodes";

    HTTPRequest request = new HTTPRequest();

    request.SetURL("http://google.com/nonexistent").
      AppendQueryParameter("q", "unity");

    HTTPResponseMemoryStreamHandler responseHandler =
      new HTTPResponseMemoryStreamHandler();

    responseHandler.AddAcceptableStatusCodeRange(200, 299);

    using (_client = new HTTPClient(request, responseHandler))
    {
      yield return StartCoroutine(_client.WaitUntilDone());
      DebugAll(_client);
    }
  }
  IEnumerator DemoQueryHeaderAndCookies()
  {
    _test = "DemoQueryHeaderAndCookies";

    HTTPRequest request = new HTTPRequest();

    request.SetURL("http://www.google.com").
      AppendQueryParameter("q", "unity").
      SetHeader("User-Agent", "dummy user agent").
      AppendCookie("name", "value").
      Get();

    using (_client = new HTTPClient(request))
    {
      yield return StartCoroutine(_client.WaitUntilDone());
      DebugAll(_client);
    }
  }