Get request method with other encoding parameters

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.