当前位置: 首页>>代码示例>>C#>>正文


C# HttpRequestMessage.ToString方法代码示例

本文整理汇总了C#中System.Net.Http.HttpRequestMessage.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# HttpRequestMessage.ToString方法的具体用法?C# HttpRequestMessage.ToString怎么用?C# HttpRequestMessage.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Net.Http.HttpRequestMessage的用法示例。


在下文中一共展示了HttpRequestMessage.ToString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: getSessionCookieAsync

        public async Task<bool> getSessionCookieAsync()
        {
            Debug.WriteLine("I'm here");
            HttpClient request = null;
            HttpResponseMessage response = null;
            HttpRequestMessage message = new HttpRequestMessage(HttpMethod.Post,
                                         ApplicationModel.Current.Domain + "/claroline/auth/login.php");

            Debug.WriteLine("Message : " + message.ToString());
            CallbackArgs args = new CallbackArgs() { login = ApplicationModel.Current.Login, password = ApplicationModel.Current.Password, operation = AllowedOperations.authenticate };
            StringContent content = new StringContent(args.ToString());
            content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/x-www-form-urlencoded");
            message.Content = content;

            request = getClient();
            response = await request.SendAsync(message);

            Debug.WriteLine("getSessionCookie : " + response.StatusCode);

            bool empty = String.IsNullOrEmpty(await response.Content.ReadAsStringAsync());
            if (empty)
            {
                CookieCreation = DateTime.Now;
            }
            Debug.WriteLine("empty : " + empty.ToString());
            return empty;
        }
开发者ID:Okhoshi,项目名称:Claroline.WindowsPhone,代码行数:27,代码来源:ClarolineClient.cs

示例2: SendAsync

		protected override async Task<HttpResponseMessage> SendAsync(
			  HttpRequestMessage request, CancellationToken cancellationToken)
		{
			string requestString = request.ToString();

			string requestBody = "";
			if (request.Content != null)
				requestBody = await request.Content.ReadAsStringAsync();
			bool wasError;
			//let other handlers process the request
			return await base.SendAsync(request, cancellationToken)
				 .ContinueWith(task =>
				 {
					string responseBody ="";
					if (task.Result.Content != null)
						responseBody = task.Result.Content.ReadAsStringAsync().Result;
					 wasError = task.Result.StatusCode >= HttpStatusCode.BadRequest;
					 
						 Logger.Instance.WriteToLog("Request: " +
							DateTime.UtcNow.ToString("G") + " " + requestString + "\r\n" + "Request body: " + requestBody, wasError);
						 Logger.Instance.WriteToLog("Response body: " +
							DateTime.UtcNow.ToString("G") + " " + responseBody, wasError);

					 return task.Result;
				 });
		}
开发者ID:kesot,项目名称:certification_backend,代码行数:26,代码来源:WebApiConfig.cs

示例3: SendAsync

        protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request,
            CancellationToken cancellationToken)
        {
            var requestHeaders = request.ToString();
            var requestBody = request.Content.ReadAsStringAsync().Result;

            var fullRequest = requestHeaders + "\r\n\r\n" + requestBody + "\r\n\r\n";

            return base.SendAsync(request, cancellationToken)
                .ContinueWith(task =>
                {
                    var response = task.Result;

                    if (task.Result.StatusCode == HttpStatusCode.InternalServerError || task.Result.StatusCode == HttpStatusCode.BadRequest)
                    {
                        var responseHeaders = task.Result.ToString();
                        var responseBody = task.Result.Content.ReadAsStringAsync().Result;

                        var fullResponse = responseHeaders + "\r\n\r\n" + responseBody;

                        response.Content = new StringContent(fullRequest + fullResponse);
                    }

                    return response;

                }, cancellationToken);
        }
开发者ID:vruc,项目名称:ConsoleApplication1,代码行数:27,代码来源:Global.asax.cs

示例4: PrintRequest

		public static async Task PrintRequest(HttpRequestMessage request){
			Debug ("REQUEST:");
			Debug (request.ToString ());
			if (request.Content != null) {
				Debug (await request.Content.ReadAsStringAsync ());
			}
		}
开发者ID:benoitjadinon,项目名称:BlueMarin,代码行数:7,代码来源:LoggingMessageHandler.cs

示例5: Main

 private static void Main(string[] args) {
     var request =
         new HttpRequestMessage(HttpMethod.Get,
                                new Uri("http://apress.com"));
     request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("text/html"));
     request.Headers.Add("X-Name", "Microsoft");
     Console.WriteLine(request.ToString());
     Console.ReadLine();
 }
开发者ID:NikolayKostadinov,项目名称:Homeworks,代码行数:9,代码来源:Program.cs

示例6: SendAsync

 protected override async Task<HttpResponseMessage> SendAsync(
     HttpRequestMessage request, CancellationToken cancellationToken)
 {
     Console.WriteLine(request.ToString());
     var response = await base.SendAsync(request, cancellationToken);
     var msg = string.Format("{0} {1}", response.StatusCode, response.ReasonPhrase);
     Console.WriteLine(msg);
     return response;
 }
开发者ID:watson-developer-cloud,项目名称:visual-recognition-aspnet,代码行数:9,代码来源:LoggingHandler.cs

示例7: SendAsync

        protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
        {
            Utils.WriteLog("Peticion -> " + request.ToString());
            var reponse = await base.SendAsync(request, cancellationToken);

            Utils.WriteLog("Respuesta -> " + reponse.ToString());

            return reponse;
        }
开发者ID:JCQuiroga,项目名称:Lab487Modulo4,代码行数:9,代码来源:LogHandler.cs

示例8: SendAsync

        protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
        {
            Utilidades.EscribirLog("Petición--------->>> "+request.ToString());
            var response = await base.SendAsync(request, cancellationToken);

            Utilidades.EscribirLog("Respuesta-------->>> " + response.ToString());

            return response;
        }
开发者ID:corregidor10,项目名称:LabModulo03WebApi,代码行数:9,代码来源:LogHandler.cs

示例9: SetRequestAsync

        public async Task SetRequestAsync(HttpRequestMessage request)
        {
            _requestLog.Headers = request.ToString();
            if (request.Content != null)
            {
                _requestLog.Body = await request.Content.ReadAsByteArrayAsync().ConfigureAwait(false);
            }

            _requestLog.StartedAt = DateTime.Now;
            _stopwatch.Start();
        }
开发者ID:raidenyn,项目名称:yandexdisk.client,代码行数:11,代码来源:Logger.cs

示例10: ProcessRequest

 protected override HttpRequestMessage ProcessRequest(HttpRequestMessage request, CancellationToken cancellationToken)
 {
     if (request != null)
     {
         this.logger.LogMessage(request.ToString(), Severity.Informational, Verbosity.Detailed);
         if (request.Content != null)
         {
             this.logger.LogMessage(string.Format(CultureInfo.InvariantCulture, "Payload: {0} ", request.Content.ReadAsStringAsync().Result), Severity.Informational, Verbosity.Detailed);
         }
     }
     return request;
 }
开发者ID:RossMerr,项目名称:azure-sdk-for-net,代码行数:12,代码来源:HttpLoggingHandler.cs

示例11: Ctor_Default

		public void Ctor_Default ()
		{
			var m = new HttpRequestMessage ();
			Assert.IsNull (m.Content, "#1");
			Assert.IsNotNull (m.Headers, "#2");
			Assert.AreEqual (HttpMethod.Get, m.Method, "#3");
			Assert.IsNotNull (m.Properties, "#4");
			Assert.IsNull (m.RequestUri, "#5");
			Assert.AreEqual (new Version (1, 1), m.Version, "#6");

			Assert.AreEqual ("Method: GET, RequestUri: '<null>', Version: 1.1, Content: <null>, Headers:\r\n{\r\n}", m.ToString (), "#7");
		}
开发者ID:narutopatel,项目名称:mono,代码行数:12,代码来源:HttpRequestMessageTest.cs

示例12: SendAsync

        protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) {

                   if (request.Method == HttpMethod.Trace) {
                       return Task<HttpResponseMessage>.Factory.StartNew(
                           () => {
                               var response = new HttpResponseMessage(HttpStatusCode.OK);
                               response.Content = new StringContent(request.ToString(), Encoding.UTF8, "message/http");
                               return response;
                           });
                    }
 
                    return base.SendAsync(request, cancellationToken);
        }
开发者ID:aehyok,项目名称:WebAPIContrib,代码行数:13,代码来源:TraceMessageHandler.cs

示例13: SendAsync

        protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
        {
            Trace.WriteLine("Request:");
            Trace.WriteLine(request.ToString());
            if (request.Content != null)
                Trace.WriteLine(await request.Content.ReadAsStringAsync());

            var response = await base.SendAsync(request, cancellationToken);

            Trace.WriteLine("Response:");
            Trace.WriteLine(response.ToString());
            if (response.Content != null)
                Trace.WriteLine(await response.Content.ReadAsStringAsync());
            return response;
        }
开发者ID:holzmaster,项目名称:OpenPr0gramm,代码行数:15,代码来源:LoggingMessageHandler.cs

示例14: SendAsync

        protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
        {
            var serialized = new HttpMessageContent(request).ReadAsByteArrayAsync().Result;

            var ms = new MemoryStream(serialized);
            var request2 = new HttpRequestMessage();
            request2.Content = new ByteArrayContent(ms.ToArray());
            request2.Content.Headers.Add("Content-Type", "application/http;msgtype=request");
            var r3 = request2.Content.ReadAsHttpRequestMessageAsync(cancellationToken).Result;

            Console.WriteLine(request.ToString());
            Console.WriteLine(r3.ToString());

            Console.WriteLine(r3.Content.ReadAsStringAsync().Result);

            var response = new HttpResponseMessage(HttpStatusCode.Accepted);
            return Task.FromResult(response);
        }
开发者ID:bSeamless,项目名称:bSeamless-IoT,代码行数:18,代码来源:NServiceBusDelegator.cs

示例15: Main

        static void Main(string[] args)
        {

            HttpRequestMessage request = new HttpRequestMessage();

            Console.WriteLine(request.ToString());

            string a = "dsfsadfa";

            a = null;


            string tokenDetailsString = string.Empty;

            using (StreamReader sr = new StreamReader(""))
            {
                tokenDetailsString = sr.ReadToEnd();
            }
        }
开发者ID:cxehud,项目名称:test,代码行数:19,代码来源:Program.cs


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