Send parameters to the Web site to read the results of the small program encountered a problem, the site is to send query parameters by get method, but I follow the format of the Web site sent the results of the query has been empty, with fiddle grab packet found that the site sent parameters are not UTF-8 encoded UrlEncode, Instead, the GBK encoded characters are sent directly to the server. Looking for a long time no solution, found a reference to a very useful article click on the Open link, slightly change the way to send the request to solve, their own record.
HTTP requests are essentially sending byte streams, so you can use sockets instead of Httpwebrequest\response in C #:
Send request:
public void SendRequest (string server,string requeststring,encoding e) {URI u= new URI (server); Socket s=new socket (addressfamily.internetnetwork, SocketType.Stream, protocoltype.tcp); S.sendtimeout=3000;s. Receivetimeout=3000;s.connect (U.host,u.port); if (s.connected) {s.send (E.getbytes (s), socketflags.none); System.Threding.Thread.Sleep (1000);//wait 1 seconds to ensure that the data sent to complete, my request is relatively simple, complex can also be judged the data sent to finish processing ...
Processing the received part can refer to the above mentioned article, mainly chunked data processing needs special processing.