Exemple #1
0
        public Stream PutEndpointStream(RestHost host, int version, string endpoint, bool enableImpersonation = true, RestPutOptions options = null)
        {
            if (options == null)
                options = new RestPutOptions();
            var processedEndpoint = ProcessPutEndpoint(endpoint, options);

            string postData = options.PostParameters.MakeQuerystring(true);
            return _proxy.Post(host, MakeEndpointUrl(host, version, processedEndpoint), postData,
                (req) => AdjustPutRequest(host, req, enableImpersonation, options));
        }
Exemple #2
0
        private string ProcessPutEndpoint(string endpoint, RestPutOptions options)
        {
            var processedEndpoint = endpoint;

            if (options.PathParameters.HasKeys())
                processedEndpoint = ReplaceTokens(endpoint, options.PathParameters);
            if (options.QueryStringParameters.HasKeys())
                processedEndpoint = BuildQueryString(processedEndpoint, options.QueryStringParameters);

            return processedEndpoint;
        }
Exemple #3
0
        public async Task<string> PutEndpointStringAsync(RestHost host, int version, string endpoint, bool enableImpersonation = true, RestPutOptions options = null)
        {
            if (options == null)
                options = new RestPutOptions();
            var processedEndpoint = ProcessPutEndpoint(endpoint, options);

            string postData = options.PostParameters.MakeQuerystring(true);

            var stream = await _proxy.PostAsync(host, MakeEndpointUrl(host, version, processedEndpoint), postData, (request) => AdjustPutRequest(host, request, enableImpersonation, options));
            return await ReadResponseStreamAsync(stream);
        }
Exemple #4
0
        private void AdjustPutRequest(RestHost host, HttpWebRequest request, bool enableImpersonation, RestPutOptions options)
        {
            AdjustRequestBase(host, request, enableImpersonation);

            if (options != null && options.AdditionalHeaders != null)
                SetAdditionalHeaders(request, options.AdditionalHeaders);

            request.Headers["Rest-Method"] = "PUT";
        }
Exemple #5
0
 /// <summary>
 /// REST PUT Request (Async)
 /// </summary>
 /// <param name="version">The REST Api version</param>
 /// <param name="endpoint">The Url without aspi.ashx and ther version</param>
 /// <param name="enableImpersonation">Use the locally authenticated user versus the default</param>
 /// <param name="options">Additional options for this request type.</param>
 /// <returns>Stream</returns>
 public Task<Stream> PutToStreamAsync(int version, string endpoint, bool enableImpersonation = true, RestPutOptions options = null)
 {
     return  Rest.PutEndpointStreamAsync(this, version, endpoint, enableImpersonation, options);
 }
Exemple #6
0
 /// <summary>
 /// REST PUT Request for JSON
 /// </summary>
 /// <param name="version">The REST Api version</param>
 /// <param name="endpoint">The Url without aspi.ashx and ther version</param>
 /// <param name="enableImpersonation">Use the locally authenticated user versus the default</param>
 /// <param name="options">Additional options for this request type.</param>
 /// <returns>dynamic</returns>
 public dynamic PutToDynamic(int version, string endpoint, bool enableImpersonation = true, RestPutOptions options = null)
 {
     var json =  Rest.PutEndpointString(this, version, endpoint, enableImpersonation, options);
     return json != null ? JsonConvert.Deserialize(json) : null;
 }
Exemple #7
0
 /// <summary>
 /// REST PUT Request for Xml
 /// </summary>
 /// <param name="version">The REST Api version</param>
 /// <param name="endpoint">The Url without aspi.ashx and ther version</param>
 /// <param name="enableImpersonation">Use the locally authenticated user versus the default</param>
 /// <param name="options">Additional options for this request type.</param>
 /// <returns>XElement</returns>
 /// 
 public XElement PutToXml(int version, string endpoint, bool enableImpersonation = true, RestPutOptions options = null)
 {
     return Rest.PutEndpointXml(this, version, endpoint, enableImpersonation, options);
 }