• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# IRestRequest类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中IRestRequest的典型用法代码示例。如果您正苦于以下问题:C# IRestRequest类的具体用法?C# IRestRequest怎么用?C# IRestRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IRestRequest类属于命名空间,在下文中一共展示了IRestRequest类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: CanPreAuthenticate

 /// <summary>
 /// Does the authentication module supports pre-authentication?
 /// </summary>
 /// <param name="client">Client executing this request</param>
 /// <param name="request">Request to authenticate</param>
 /// <param name="credentials">The credentials to be used for the authentication</param>
 /// <returns>true when the authentication module supports pre-authentication</returns>
 public bool CanPreAuthenticate(IRestClient client, IRestRequest request, ICredentials credentials)
 {
     var cred = credentials?.GetCredential(client.BuildUri(request, false), AuthenticationMethod);
     if (cred == null)
         return false;
     return true;
 }
开发者ID:evnik,项目名称:restsharp.portable,代码行数:14,代码来源:SimpleAuthenticator.cs


示例2: IsCanProcessRequest

 protected override bool IsCanProcessRequest(IRestRequest request)
 {
     return (request.Verb == HttpVerb.Post || request.Verb == HttpVerb.Put)
         && request.GetType() == typeof(RestRequest)
         && request.Parameters != null
         && request.Parameters.Any(p => p.Value is FileParameter);
 }
开发者ID:VeselovAndrey,项目名称:RestArt,代码行数:7,代码来源:MultipartFormDataMessageBuilder.cs


示例3: ApplyOptions

        public void ApplyOptions(IRestRequest request, bool isGet)
        {
            if (_options == null)
            {
                return;
            }
            ApplyOptionsStrategy applyOptionsStrategy = isGet
                                                            ? (ApplyOptionsStrategy)
                                                              new GetApplyOptionsStrategy(request, _options)
                                                            : new PostApplyOptionsStrategy(request, _options);
            if (_options.Pretty)
            {
                applyOptionsStrategy.ApplyPretty();
            }

            if (_options.Fields != null && _options.Fields.Count > 0)
            {
                applyOptionsStrategy.ApplyFields();
            }

            if (_options.Expand != null && _options.Expand.Count > 0)
            {
                applyOptionsStrategy.ApplyExpand();
            }
            applyOptionsStrategy.Finish();
        }
开发者ID:pocheptsov,项目名称:nasana,代码行数:26,代码来源:AsanaOptionsApplier.cs


示例4: PopulateSubEntities

 private void PopulateSubEntities(IRestRequest request)
 {
     new LobImageFilePopulator(_definition.Front, "front").Populate(request);
     new LobImageFilePopulator(_definition.Back, "back").Populate(request);
     if (_definition.Data != null) new DataPopulator(_definition.Data).Populate(request);
     if (_definition.MetaData != null) new MetaDataPopulator(_definition.MetaData).Populate(request);
 }
开发者ID:CRodriguez25,项目名称:lob-dotnet,代码行数:7,代码来源:AreaMailingDefinitionPopulator.cs


示例5: ReplaceAcceptWithJson

 private void ReplaceAcceptWithJson(IRestRequest restRequest)
 {
     foreach (var parameter in restRequest.Parameters.Where(p => p.Name == "Accept"))
     {
         parameter.Value = "application/json";
     }
 }
开发者ID:DefiSolutions,项目名称:YouTrack.Rest,代码行数:7,代码来源:RestFileRequestFactory.cs


示例6: RestException

 public RestException(IRestRequest request, IRestResponse response)
     : base(string.Format("The endpoint at '{0}' didn't respond with 'OK'. Instead it was '{1}'.",
         response.ResponseUri, response.StatusCode), response.ErrorException??new Exception(response.Content))
 {
     Request = request;
     Response = response;
 }
开发者ID:AcklenAvenue,项目名称:Pepino,代码行数:7,代码来源:RestException.cs


示例7: BaseRestService

 public BaseRestService(IRestHandler restHandler, IFormat formator, IRestRequest restRequest)
 {
     _restHandler = restHandler;
     _formator = formator;
     _restRequest = restRequest;
     Initialize();
 }
开发者ID:smacinn,项目名称:IRestService,代码行数:7,代码来源:baseRestService.cs


示例8: GetBasicContent

        /// <summary>
        /// Gets the basic content (without files) for a request
        /// </summary>
        /// <param name="client">The REST client that will execute the request</param>
        /// <param name="request">REST request to get the content for</param>
        /// <returns>The HTTP content to be sent</returns>
        internal static IHttpContent GetBasicContent([CanBeNull] this IRestClient client, IRestRequest request)
        {
            IHttpContent content;
            var parameters = client.MergeParameters(request);
            var body = parameters.FirstOrDefault(x => x.Type == ParameterType.RequestBody);
            if (body != null)
            {
                content = request.GetBodyContent(body);
            }
            else
            {
                if (client.GetEffectiveHttpMethod(request) == Method.POST)
                {
                    var getOrPostParameters = parameters.GetGetOrPostParameters().ToList();
                    if (getOrPostParameters.Count != 0)
                    {
                        content = new PostParametersContent(getOrPostParameters);
                    }
                    else
                    {
                        content = null;
                    }
                }
                else
                {
                    content = null;
                }
            }

            return content;
        }
开发者ID:ReachContact,项目名称:restsharp.portable,代码行数:37,代码来源:RestClientExtensions.cs


示例9: Authenticate

 /// <summary>
 /// Modifies the request to ensure that the authentication requirements are met.
 /// </summary>
 /// <param name="client">Client executing this request</param>
 /// <param name="request">Request to authenticate</param>
 public void Authenticate(IRestClient client, IRestRequest request)
 {
     // only add the Authorization parameter if it hasn't been added by a previous Execute
     if (request.Parameters.Any(p => p.Name != null && p.Name.Equals("Authorization", StringComparison.OrdinalIgnoreCase)))
         return;
     request.AddParameter("Authorization", this._authHeader, ParameterType.HttpHeader);
 }
开发者ID:ATLCTO,项目名称:CustomerIOSharp,代码行数:12,代码来源:FixedHttpBasicAuthenticator.cs


示例10: Build

        public HttpRequestMessage Build(IRestRequest request, IDictionary<string, string> persistentHeaders)
        {
            if (!this.IsCanProcessRequest(request))
                return null;

            HttpRequestMessage message = this.BuildMessage(request);

            // Set headers
            message.Headers.Add("Accept", "application/json");

            // Add persistent headers
            if (request.Headers != null) {
                foreach (var header in request.Headers)
                    this.AddHeader(header.Key, header.Value, message);
            }

            // Add message headers
            if (persistentHeaders != null) {
                foreach (var header in persistentHeaders)
                    if (request.Headers == null || !request.Headers.ContainsKey(header.Key))
                        this.AddHeader(header.Key, header.Value, message);
            }

            return message;
        }
开发者ID:VeselovAndrey,项目名称:RestArt,代码行数:25,代码来源:MessageBuilderBase.cs


示例11: Apply

 internal void Apply(IRestRequest request)
 {
     _ops.ForEach((op) =>
     {
         request.AddQueryParameter(op.Type.ToString(), op.Value);
     });
 }
开发者ID:tvhnet2014,项目名称:stream-net,代码行数:7,代码来源:FeedFilter.cs


示例12: Authenticate

        public void Authenticate(IRestClient client, IRestRequest request)
        {
            if (request.Parameters.Exists(p => p.Name.Equals("Cookie", StringComparison.InvariantCultureIgnoreCase)))
                return;

            request.AddParameter("cookie", _authHeader, ParameterType.HttpHeader);
        }
开发者ID:gooodhub,项目名称:Jira.NET,代码行数:7,代码来源:CookieBasedAuthenticator.cs


示例13: BuildDebugUri

 /// <summary>
 /// Assembles URL to call based on parameters, method and resource
 /// </summary>
 /// <param name="client">RestClient performing the execution</param>
 /// <param name="request">RestRequest to execute</param>
 /// <returns>Assembled System.Uri</returns>
 /// <remarks>
 /// RestClient's BuildUri purposefully leaves off the parameters from the uri it builds when the request 
 /// is a POST, PUT, or PATCH.  This extension method aims to undo this feature for debugging reasons
 /// </remarks>
 public static Uri BuildDebugUri(this IRestClient client, IRestRequest request)
 {
     var uri = client.BuildUri(request);
     if (request.Method != Method.POST &&
         request.Method != Method.PUT &&
         request.Method != Method.PATCH)
     {
         return uri;
     }
     else
     {
         var queryParameters = from p in request.Parameters
                               where p.Type == ParameterType.GetOrPost
                               select string.Format("{0}={1}", Uri.EscapeDataString(p.Name), Uri.EscapeDataString(p.Value.ToString()));
         if (!queryParameters.Any())
         {
             return uri;
         }
         else
         {
             var path = uri.OriginalString.TrimEnd('/');
             var query = string.Join("&", queryParameters);
             return new Uri(path + "?" + query);
         }
     }
 }
开发者ID:otint,项目名称:github-issues-via-feedback-form,代码行数:36,代码来源:RestSharpExts.cs


示例14: ApplyOptions

 private void ApplyOptions(IRestRequest request, bool isGet)
 {
     if (_asanaOptionsApplier != null)
     {
         _asanaOptionsApplier.ApplyOptions(request, true);
     }
 }
开发者ID:pocheptsov,项目名称:nasana,代码行数:7,代码来源:AsanaRequest.cs


示例15: LogRequest

        private void LogRequest(RestClient restClient, IRestRequest request, IRestResponse response, long durationMs)
        {
            var requestToLog = new
            {
                resource = request.Resource,
                // Parameters are custom anonymous objects in order to have the parameter type as a nice string
                // otherwise it will just show the enum value
                parameters = request.Parameters.Select(parameter => new
                {
                    name = parameter.Name,
                    value = parameter.Value,
                    type = parameter.Type.ToString()
                }),
                // ToString() here to have the method as a nice string otherwise it will just show the enum value
                method = request.Method.ToString(),
                // This will generate the actual Uri used in the request
                uri = restClient.BuildUri(request),
            };

            var responseToLog = new
            {
                statusCode = response.StatusCode,
                content = response.Content,
                headers = response.Headers,
                // The Uri that actually responded (could be different from the requestUri if a redirection occurred)
                responseUri = response.ResponseUri,
                errorMessage = response.ErrorMessage,
            };

            Trace.Write(string.Format("Request completed in {0} ms, Request: {1}, Response: {2}",
                    durationMs,
                    JsonConvert.SerializeObject(requestToLog),
                    JsonConvert.SerializeObject(responseToLog)));
        }
开发者ID:CactusSoft,项目名称:Cactus.Fileserver,代码行数:34,代码来源:CrudIntegrationTest.cs


示例16: GetContent

        /// <summary>
        /// Gets the content for a request
        /// </summary>
        /// <param name="client">The REST client that will execute the request</param>
        /// <param name="request">REST request to get the content for</param>
        /// <returns>The HTTP content to be sent</returns>
        internal static IHttpContent GetContent([CanBeNull] this IRestClient client, IRestRequest request)
        {
            HttpContent content;
            var parameters = client.MergeParameters(request);
            var collectionMode = request?.ContentCollectionMode ?? ContentCollectionMode.MultiPartForFileParameters;
            if (collectionMode != ContentCollectionMode.BasicContent)
            {
                var fileParameters = parameters.GetFileParameters().ToList();
                if (collectionMode == ContentCollectionMode.MultiPart || fileParameters.Count != 0)
                {
                    content = client.GetMultiPartContent(request);
                }
                else
                {
                    content = client.GetBasicContent(request);
                }
            }
            else
            {
                content = client.GetBasicContent(request);
            }

            if (content == null)
                return null;

            return new DefaultHttpContent(content);
        }
开发者ID:evnik,项目名称:restsharp.portable,代码行数:33,代码来源:RestClientExtensions.cs


示例17: Authenticate

        public void Authenticate(IRestClient client, IRestRequest request)
        {
            DateTime signingDate = DateTime.UtcNow;
            SetContentMd5(request);
            SetContentSha256(request);
            SetHostHeader(client, request);
            SetDateHeader(request, signingDate);
            SortedDictionary<string, string> headersToSign = GetHeadersToSign(request);
            string signedHeaders = GetSignedHeaders(headersToSign);
            string region = Regions.GetRegion(client.BaseUrl.Host);
            string canonicalRequest = GetCanonicalRequest(client, request, headersToSign);
            byte[] canonicalRequestBytes = System.Text.Encoding.UTF8.GetBytes(canonicalRequest);
            string canonicalRequestHash = BytesToHex(ComputeSha256(canonicalRequestBytes));
            string stringToSign = GetStringToSign(region, canonicalRequestHash, signingDate);
            byte[] signingKey = GenerateSigningKey(region, signingDate);

            byte[] stringToSignBytes = System.Text.Encoding.UTF8.GetBytes(stringToSign);

            byte[] signatureBytes = SignHmac(signingKey, stringToSignBytes);

            string signature = BytesToHex(signatureBytes);

            string authorization = GetAuthorizationHeader(signedHeaders, signature, signingDate, region);
            request.AddHeader("Authorization", authorization);
        }
开发者ID:balamurugana,项目名称:minio-dotnet,代码行数:25,代码来源:V4Authenticator.cs


示例18: ExecuteInternal

		private async Task<IRestResponse> ExecuteInternal(IRestRequest request, string httpMethod, Func<IHttp, string, Task<HttpResponse>> getResponse)
		{
			AuthenticateIfNeeded(this, request);

			// add Accept header based on registered deserializers
			var accepts = string.Join(", ", AcceptTypes.ToArray());
			this.AddDefaultParameter("Accept", accepts, ParameterType.HttpHeader);

			IRestResponse response = new RestResponse();
			try
			{
				var http = HttpFactory.Create();

				ConfigureHttp(request, http);

                //TODO: Add support for Proxy
				//ConfigureProxy(http);

				response = ConvertToRestResponse(request, await getResponse(http, httpMethod));
				response.Request = request;
				response.Request.IncreaseNumAttempts();

			}
			catch (Exception ex)
			{
				response.ResponseStatus = ResponseStatus.Error;
				response.ErrorMessage = ex.Message;
				response.ErrorException = ex;
			}

			return response;
		}
开发者ID:fmmendo,项目名称:RestSharp,代码行数:32,代码来源:RestClient.Sync.cs


示例19: PostApi

        private BillingConnectorResponse PostApi(string segment, IRestRequest request)
        {
            try
            {
                log.InfoFormat("Invoking billing API on {0} with segment {1}", configuration.Url, segment);

                request.AddHeader("apikey", configuration.ApiKey);

                var response = client.Post(request);

                if (response.StatusCode == HttpStatusCode.OK)
                    return new BillingConnectorResponse(true);

                var failureMessage =
                    string.Format(
                        "Call to billing API return non OK status code. The status code was {0}. The response status code was {1}. The error description is {2}",
                        response.StatusCode, response.ResponseStatus, response.ErrorMessage);

                log.ErrorFormat(failureMessage);
            }
            catch (Exception e)
            {
                log.ErrorFormat("Failed to invoke billing API on {0} because {1}", configuration.Url, e);
            }
            return new BillingConnectorResponse(false);
        }
开发者ID:rjonker1,项目名称:lightstone-data-platform,代码行数:26,代码来源:DefaultBillingConnector.cs


示例20: When

 public When(IRestClient client, IRestRequest request, IRestResponse response)
 {
     this.client = client;
     this.request = request;
     this.response = response;
     data = new Object();
 }
开发者ID:sakthijas,项目名称:ProtoTest.Golem,代码行数:7,代码来源:When.cs



注:本文中的IRestRequest类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IRestResponse类代码示例发布时间:2022-05-24
下一篇:
C# IRestClient类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap