HttpWebRequest.GetRequestStream : What it does?

后端 未结 2 1332
耶瑟儿~
耶瑟儿~ 2021-01-30 11:12

Code exemple:

HttpWebRequest request =
   (HttpWebRequest)HttpWebRequest.Create(\"http://some.existing.url\");

request.Method = \"POST\";
request.ContentType          


        
2条回答
  •  悲&欢浪女
    2021-01-30 11:40

    Getting the request stream does not trigger the post, but closing the stream does. Post data is sent to the server in the following way:

    1. A connection is opened to the host
    2. Send request and headers
    3. Write Post data
    4. Wait for a response.

    The act of flushing and closing the stream is the final step, and once the input stream is closed (i.e. the client has sent what it needs to the server), then the server can return a response.

提交回复
热议问题