简体   繁体   English

如何在C#中发送已经准备好的字符串http请求

[英]how to send already prepared in string http request in C#

Http request as string C# Http 请求作为字符串 C#

I want to send http request as it is given to me from user without any changing.我想发送 http 请求,因为它是从用户给我的,没有任何更改。

From user i get string从用户我得到字符串

  GET / HTTP/1.1 
  Host: examplesite.com 
  Content-Length: 15 

So i want to send it as it is without any changing or parsing, is it any library to do this in C#?所以我想按原样发送它而不进行任何更改或解析,是否有任何库可以在 C# 中执行此操作?

How are you capturing the users prepared URL?您如何捕获用户准备的 URL?

With the least amount of information available if you trying to create a simple request you can use the following:如果您尝试创建一个简单的请求,可用最少的信息,您可以使用以下内容:

    public static void Main()
    {
        // User Prepared Url
        var url = "https://www.google.com";

        // Create a 'WebRequest' object with the specified url. 
        WebRequest myWebRequest = WebRequest.Create(url); 

        // Send the 'WebRequest' and wait for response.
        WebResponse myWebResponse = myWebRequest.GetResponse(); 

        // Release resources of response object.
        myWebResponse.Close();
    }

There is no logic in checking that the Url is valid etc.检查 Url 是否有效等没有逻辑。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM