Preface
Question: 1. What are special characters?
2. Why special characters?
A: special characters refer to symbols that are less frequently used than traditional or commonly used characters and are difficult to directly input, such as mathematical symbols, Unit symbols, and tabs.
Some symbols cannot be directly transmitted in the URL. If you want to pass these special symbols in the URL, you need to use their encoding. The encoding format is % plus the characters' ASCII code, that is, a percent sign %, followed by the corresponding characters' ASCII (hexadecimal) code value. For example, the Space Encoding value is "% 20 ".
Problem
How to return HTTP Response content line by line instead of using the entire content as a string
Design
Httpwebrequest. the getresponse () method obtains the HTTP Response stream, transmits the stream to the streamreader () constructor, and then uses streamreader in a while loop. the Readline () method reads data row by row.
Solution
public static void stream() { Stream st = null; StreamReader sr = new StreamReader(st); string line = null; Console.WriteLine("HTTP Response is line-by-line:"); while((line=sr.ReadLine())!=null) { Console.WriteLine(line); } st.Close(); sr.Close(); }
I think
Static void main (string [] ARGs) {stream ();} public static void stream () {string url = "www.baidu.com "; // define a byte array byte [] array = encoding. ASCII. getbytes (URL); // assign the array to the data stream memorystream = new memorystream (array); streamreader sr = new streamreader (Stream); // stream ST = NULL; // streamreader sr = new streamreader (ST); string line = NULL; console. writeline ("HTTP response is line-by-line :"); While (line = Sr. Readline ())! = NULL) {console. writeline (line);} stream. Close (); Sr. Close ();}
Annotation
The three basic methods used to send HTTP requests (WebClient, webreqest, and httpwebrequest) support returning the associated HTTP responses in the form of stream objects through a certain method.