private IEnumerator UnsignedRequestActions(string path, object reqBody, string appKey) { Dictionary <string, string> headers = new Dictionary <string, string>(); headers["x-tsumanga-app"] = appKey; WWW req = new WWW(WebServiceHost + path, Encoding.UTF8.GetBytes(WebData.JsonSerialise(reqBody)), headers); yield return(req); }
/// <summary> /// A WWW with an x-tsumanga-sign header signing the POST data /// using the specified key. /// </summary> /// <returns> /// The WWW object /// </returns> /// <param name='url'> /// URL (to be appended to the host from the constructor) /// </param> /// <param name='key'> /// A byte array that will be the HMAC key used to sign the data. /// </param> /// <param name='body'> /// An object that will be serialised to JSON and encoded as UTF8, /// which will then be used with the key to make an HMAC signature. /// </param> internal WWW SignedWWW(string url, byte[] key, object body, string methodOverride) { string json = (body is string) ? body as string : WebData.JsonSerialise(body); Dictionary <string, string> headers = new Dictionary <string, string>(); headers["Content-Type"] = "application/json"; byte[] data = Encoding.UTF8.GetBytes(json); // now use gzip content encoding if it makes the request smaller byte[] zippedData = WebData.Gzip(data); if (zippedData.Length < data.Length) { data = zippedData; headers["Content-Encoding"] = "gzip"; } headers["x-tsumanga-sign"] = WebData.HexDigest(key, data); if (methodOverride != null) { headers["X-HTTP-Method-Override"] = methodOverride; } return(new WWW(WebServiceHost + url, data, headers)); }