當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。