Esempio n. 1
0
        private LRSResponse SaveDocument(String resource, Dictionary <String, String> queryParams, Document document)
        {
            var r = new LRSResponse();

            var req = new MyHTTPRequest();

            req.method      = "PUT";
            req.resource    = resource;
            req.queryParams = queryParams;
            req.contentType = document.contentType;
            req.content     = document.content;

            var res = MakeSyncRequest(req);

            if (res.status != HttpStatusCode.NoContent)
            {
                r.success       = false;
                r.httpException = res.ex;
                r.SetErrMsgFromBytes(res.content);
                return(r);
            }

            r.success = true;

            return(r);
        }
Esempio n. 2
0
        async Task <LRSResponse> SaveDocument(string resource, Dictionary <string, string> queryParams, Document document, RequestType requestType = RequestType.put)
        {
            var r = new LRSResponse();

            var req = new MyHTTPRequest();

            if (requestType == RequestType.post)
            {
                req.method = HttpMethod.Post;
            }
            else
            {
                req.method = HttpMethod.Put;
            }
            req.resource    = resource;
            req.queryParams = queryParams;
            req.contentType = document.contentType;
            req.content     = document.content;
            if (document.etag != null)
            {
                req.headers = new Dictionary <string, string>();
                req.headers.Add("If-Match", document.etag);
            }
            var res = await MakeRequest(req);

            if (res.status != HttpStatusCode.NoContent)
            {
                r.success       = false;
                r.httpException = res.ex;
                r.SetErrMsgFromBytes(res.content, (int)res.status);
                return(r);
            }

            r.success = true;

            return(r);
        }
Esempio n. 3
0
        async Task <LRSResponse> DeleteDocument(string resource, Dictionary <string, string> queryParams)
        {
            var r = new LRSResponse();

            var req = new MyHTTPRequest();

            req.method      = HttpMethod.Delete;
            req.resource    = resource;
            req.queryParams = queryParams;

            var res = await MakeRequest(req);

            if (res.status != HttpStatusCode.NoContent)
            {
                r.success       = false;
                r.httpException = res.ex;
                r.SetErrMsgFromBytes(res.content, (int)res.status);
                return(r);
            }

            r.success = true;

            return(r);
        }
Esempio n. 4
0
        private LRSResponse DeleteDocument(string resource, Dictionary <string, string> queryParams)
        {
            var r = new LRSResponse();

            var req = new MyHTTPRequest();

            req.method      = "DELETE";
            req.resource    = resource;
            req.queryParams = queryParams;

            var res = MakeSyncRequest(req);

            if (res.status != HttpStatusCode.NoContent)
            {
                r.success       = false;
                r.httpException = res.ex;
                r.SetErrMsgFromBytes(res.content);
                return(r);
            }

            r.success = true;

            return(r);
        }