public virtual WebRequest CreateKeyRequest(Cryptor cryptor, string method, string input) { string address = KEY_API; if (includeParametersInRequestAddress) { address += input; } WebRequest webRequest = (HttpWebRequest)System.Net.WebRequest.Create(address); webRequest.Method = method; webRequest.Timeout = 60000; webRequest.ContentType = "application/x-www-form-urlencoded"; webRequest = AddKeyHeaders(cryptor, webRequest); byte[] inputBytes = Encoding.UTF8.GetBytes(input); webRequest.ContentLength = input.Length; using (var dataStream = webRequest.GetRequestStream()) { dataStream.Write(inputBytes, 0, input.Length); } return(webRequest); }
public virtual string DoKeyRequest(string parameters) { Cryptor cryptor = new Cryptor(); cryptor.CalcSign(secret, signBaseUrl + parameters); WebRequest webRequest = CreateKeyRequest(cryptor, keyMethod, parameters); return(GetResponseForRequest(webRequest)); }
public string DoKeyRequest(string parameters) { Cryptor cryptor = new Cryptor(); cryptor.CalcSign(secret, parameters); WebRequest webRequest = CreateKeyRequest(cryptor, parameters); return(GetResponseForRequest(webRequest)); }
public WebRequest CreateKeyRequest(Cryptor cryptor, string input) { string address = KEY_API + "?" + input; WebRequest webRequest = (HttpWebRequest)System.Net.WebRequest.Create(address); webRequest.Method = "POST"; webRequest.Timeout = 20000; webRequest.ContentType = "application/x-www-form-urlencoded"; webRequest.Headers.Add("Key", key); webRequest.Headers.Add("Sign", cryptor.sign); byte[] inputBytes = Encoding.UTF8.GetBytes(input); webRequest.ContentLength = input.Length; using (var dataStream = webRequest.GetRequestStream()) { dataStream.Write(inputBytes, 0, input.Length); } return(webRequest); }
public abstract WebRequest AddKeyHeaders(Cryptor cryptor, WebRequest webRequest);
public override WebRequest AddKeyHeaders(Cryptor cryptor, WebRequest webRequest) { webRequest.Headers.Add("apisign", cryptor.sign); return(webRequest); }