public Task<ConnectionStatus> Delete(string path, string data) { var restRequest = new RestRequest(); restRequest.Method = Method.DELETE; restRequest.Uri = path; if (!string.IsNullOrEmpty(data)) { restRequest.Body = Encoding.UTF8.GetBytes(data); } restRequest.Headers = new Dictionary<string, string>(); restRequest.Headers.Add("Content-Type", "application/json"); return Task.Factory.StartNew<ConnectionStatus>(() => { return this.Execute(restRequest); }); }
public ConnectionStatus PutSync(string path, string data) { var restRequest = new RestRequest(); restRequest.Method = Method.PUT; restRequest.Uri = path; if (!string.IsNullOrEmpty(data)) { restRequest.Body = Encoding.UTF8.GetBytes(data); } restRequest.Headers = new Dictionary<string, string>(); restRequest.Headers.Add("Content-Type", "application/json"); RestResponse result = GetClient().execute(restRequest); return new ConnectionStatus(DecodeStr(result.Body)); }
public Task<ConnectionStatus> Post(string path, string data) { var restRequest = new RestRequest(); restRequest.Method = Method.POST; restRequest.Uri = path; if (!string.IsNullOrEmpty(data)) { restRequest.Body = Encoding.UTF8.GetBytes(data); } restRequest.Headers = new Dictionary<string, string>(); restRequest.Headers.Add("Content-Type", "application/json"); return Task.Factory.StartNew<ConnectionStatus>(() => { var result = GetClient().execute(restRequest); return new ConnectionStatus(DecodeStr(result.Body)); }); }
public ConnectionStatus HeadSync(string path) { var restRequest = new RestRequest(); restRequest.Method = Method.HEAD; restRequest.Uri = path; restRequest.Headers = new Dictionary<string, string>(); restRequest.Headers.Add("Content-Type", "application/json"); RestResponse result = GetClient().execute(restRequest); return new ConnectionStatus(DecodeStr(result.Body)); }
public Task<ConnectionStatus> Head(string path) { var restRequest = new RestRequest(); restRequest.Method = Method.HEAD; restRequest.Uri = path; restRequest.Headers = new Dictionary<string, string>(); restRequest.Headers.Add("Content-Type", "application/json"); return Task.Factory.StartNew<ConnectionStatus>(()=> { var result = GetClient().execute(restRequest); return new ConnectionStatus(DecodeStr(result.Body)); }); }
public Task<ConnectionStatus> Delete(string path) { var restRequest = new RestRequest(); restRequest.Method = Method.DELETE; restRequest.Uri = path; restRequest.Headers = new Dictionary<string, string>(); restRequest.Headers.Add("Content-Type", "application/json"); return Task.Factory.StartNew<ConnectionStatus>(() => { return this.Execute(restRequest); }); }
private ConnectionStatus Execute(RestRequest restRequest) { //RestResponse result = GetClient().execute(restRequest); // if (!this._resourceLock.WaitOne(this._timeout)) { var m = "Could not start the thrift operation before the timeout of " + this._timeout + "ms completed while waiting for the semaphore"; return new ConnectionStatus(this._connectionSettings, new TimeoutException(m)); } try { Rest.Client client = null; if (!this._clients.TryDequeue(out client)) { var m = string.Format("Could dequeue a thrift client from internal socket pool of size {0}", this._poolSize); var status = new ConnectionStatus(this._connectionSettings, new Exception(m)); return status; } try { if (!client.InputProtocol.Transport.IsOpen) client.InputProtocol.Transport.Open(); var result = client.execute(restRequest); if (result.Status == Status.OK || result.Status == Status.CREATED || result.Status == Status.ACCEPTED) return new ConnectionStatus(this._connectionSettings, DecodeStr(result.Body)); else { var connectionException = new ConnectionException( msg: Enum.GetName(typeof (Status), result.Status), statusCode: (int)result.Status, response: DecodeStr(result.Body) ); return new ConnectionStatus(this._connectionSettings, connectionException); } } catch { throw; } finally { //make sure we make the client available again. this._clients.Enqueue(client); } } catch (Exception e) { return new ConnectionStatus(this._connectionSettings, e); } finally { this._resourceLock.Release(); } }
public ConnectionStatus HeadSync(string path) { var restRequest = new RestRequest(); restRequest.Method = Method.HEAD; restRequest.Uri = path; restRequest.Headers = new Dictionary<string, string>(); restRequest.Headers.Add("Content-Type", "application/json"); return this.Execute(restRequest); }
public ConnectionStatus PostSync(string path, string data) { var restRequest = new RestRequest(); restRequest.Method = Method.POST; restRequest.Uri = path; if (!string.IsNullOrEmpty(data)) { restRequest.Body = Encoding.UTF8.GetBytes(data); } restRequest.Headers = new Dictionary<string, string>(); restRequest.Headers.Add("Content-Type", "application/json"); return this.Execute(restRequest); }
public void Delete(string path, string data, Action<ConnectionStatus> callback) { var restRequest = new RestRequest(); restRequest.Method = Method.DELETE; restRequest.Uri = path; if (!string.IsNullOrEmpty(data)) { restRequest.Body = Encoding.UTF8.GetBytes(data); } restRequest.Headers = new Dictionary<string, string>(); restRequest.Headers.Add("Content-Type", "application/json"); GetClient().execute(restRequest); }
public void Head(string path, Action<ConnectionStatus> callback) { var restRequest = new RestRequest(); restRequest.Method = Method.HEAD; restRequest.Uri = path; restRequest.Headers = new Dictionary<string, string>(); restRequest.Headers.Add("Content-Type", "application/json"); GetClient().execute(restRequest); }
public RestResponse execute(RestRequest request) { send_execute(request); return recv_execute(); }
public void Read(TProtocol iprot) { TField field; iprot.ReadStructBegin(); while (true) { field = iprot.ReadFieldBegin(); if (field.Type == TType.Stop) { break; } switch (field.ID) { case 1: if (field.Type == TType.Struct) { request = new RestRequest(); request.Read(iprot); __isset.request = true; } else { TProtocolUtil.Skip(iprot, field.Type); } break; default: TProtocolUtil.Skip(iprot, field.Type); break; } iprot.ReadFieldEnd(); } iprot.ReadStructEnd(); }
public void send_execute(RestRequest request) { oprot_.WriteMessageBegin(new TMessage("execute", TMessageType.Call, seqid_)); var args = new execute_args(); args.Request = request; args.Write(oprot_); oprot_.WriteMessageEnd(); oprot_.Transport.Flush(); }